Skip to content

Conversation

@wangtsiao
Copy link

Description

Adds auto-scroll functionality to text selection, enabling seamless multi-page selection when pointer approaches viewport edges.

Changes

  • Auto-scroll triggers within 50-100px of viewport edges during text selection
  • Uses requestAnimationFrame for smooth scrolling
  • Automatically stops when selection ends or pointer moves away
  • Supports all four directional scrolling (up, down, left, right)

Questions

Edge Threshold Configuration

I initially set all edge thresholds (top, bottom, left, right) to 50px.

However, when I was testing with the snippet example, I noticed that 50px wasn't quite enough for the top edge - the auto-scroll wouldn't kick in reliably when I moved my cursor near the top.

As a result, I increased only the top threshold to 100px while keeping the others at 50px:

private readonly AUTO_SCROLL_TOP_THRESHOLD = 100;
private readonly AUTO_SCROLL_BOTTOM_THRESHOLD = 50;
private readonly AUTO_SCROLL_LEFT_THRESHOLD = 50;
private readonly AUTO_SCROLL_RIGHT_THRESHOLD = 50;

This is my first PR here! I'm absolutely loving this project and it's been a pleasure working with the codebase. Please feel free to let me know if there's anything I should improve. Thanks so much for your time! 💙

Automatically scroll viewport when pointer approaches edges during
text selection, enabling seamless multi-page selection.
@vercel
Copy link

vercel bot commented Oct 17, 2025

@wangtsiao is attempting to deploy a commit to the OpenBook Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant