Skip to content

Make highlight overlays sticky on nonstandard scrolling #390

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SubsequentlySneeds
Copy link

Fixes #263

When scrolling inside an internal scrollable element or on pages with custom scrolling behavior, highlight overlays would desync from their target element. This fixes the issue by watching for relevant events and reattaching the overlays for a short period. One final attempt is delayed to catch even longer scrolling animations.

If performance suffers on low-end devices, toRunEachFrame(updateHighlightOverlayPositions, 200, 1000) can be changed to a simple requestAnimationFrame(updateHighlightOverlayPositions) to fix internal element scrolling (such as Obsidian web pages), but pages that intercept wheel events and do custom scrolling (like Grok) will remain desynced. If performance is not an issue, toRunEachFrame can be changed to run for a longer period or indefinitely.

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

Successfully merging this pull request may close these issues.

BUG: Highlight did not stick to paragraph when scrolling
1 participant