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

fix: smooth scrolling for repetitive keydown #4328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions content_scripts/scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const CoreScroller = {
calibrationBoundary: 150,

// Scroll element by a relative amount (a number) in some direction.
scroll(element, direction, amount, continuous) {
scroll(element, direction, amount, continuous, forceRepeat) {
if (continuous == null) continuous = true;
if (!amount) {
return;
Expand All @@ -253,7 +253,7 @@ const CoreScroller = {

// We don't activate new animators on keyboard repeats; rather, the most-recently activated
// animator continues scrolling.
if (this.lastEvent != null ? this.lastEvent.repeat : undefined) {
if (this.lastEvent != null && this.lastEvent.repeat && !forceRepeat) {
return;
}

Expand Down Expand Up @@ -429,22 +429,22 @@ const Scroller = {
if (rect.bottom < 0) {
amount = rect.bottom - Math.min(rect.height, window.innerHeight);
element = findScrollableElement(element, "y", amount, 1);
CoreScroller.scroll(element, "y", amount, false);
CoreScroller.scroll(element, "y", amount, false, true);
} else if (window.innerHeight < rect.top) {
amount = rect.top + Math.min(rect.height - window.innerHeight, 0);
element = findScrollableElement(element, "y", amount, 1);
CoreScroller.scroll(element, "y", amount, false);
CoreScroller.scroll(element, "y", amount, false, true);
}

// Scroll x axis.
if (rect.right < 0) {
amount = rect.right - Math.min(rect.width, window.innerWidth);
element = findScrollableElement(element, "x", amount, 1);
CoreScroller.scroll(element, "x", amount, false);
CoreScroller.scroll(element, "x", amount, false, true);
} else if (window.innerWidth < rect.left) {
amount = rect.left + Math.min(rect.width - window.innerWidth, 0);
element = findScrollableElement(element, "x", amount, 1);
CoreScroller.scroll(element, "x", amount, false);
CoreScroller.scroll(element, "x", amount, false, true);
}
}
},
Expand Down