Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export the redraw function from the TextAnnotator #103

Open
oleksandr-danylchenko opened this issue Jun 6, 2024 · 0 comments
Open

Export the redraw function from the TextAnnotator #103

oleksandr-danylchenko opened this issue Jun 6, 2024 · 0 comments

Comments

@oleksandr-danylchenko
Copy link
Contributor

Context

By default, the highlights layer gets redrawn whenever a user scrolls a page. To trigger that redraw process, the scroll event listener is attached to the document.body:

// Refresh on scroll
const onScroll = () => redraw(true);
document.addEventListener('scroll', onScroll, { capture: true, passive: true });

Issue

Unfortunately, when the TextAnnotator is rendered on a page with the overflow: hidden styles applied to the body - no scroll events will be processed. Which will make the highlights look out of sync with the annotated content.
Such style is common for web apps written with mobile-development frameworks like the Ionic Capacitor.

Screen.Recording.2024-06-06.at.12.30.46.mov

Suggested Changes

Export the redraw method from the TextAnnotator instance to allow manual triggering for the highlights layer updates. The consuming app will know where the alternative scroll listener should be attached and when the redrawing should be triggered 👌🏻

oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Jun 6, 2024
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Jul 9, 2024
# Conflicts:
#	packages/text-annotator/src/TextAnnotator.ts
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Jul 9, 2024
# Conflicts:
#	packages/text-annotator/src/TextAnnotator.ts
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Oct 7, 2024
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Oct 7, 2024
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Oct 7, 2024
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Oct 9, 2024
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Oct 29, 2024
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Oct 29, 2024
# Conflicts:
#	packages/text-annotator/src/utils/index.ts
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Nov 4, 2024
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Nov 4, 2024
oleksandr-danylchenko added a commit to oleksandr-danylchenko/text-annotator-js that referenced this issue Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant