Fixes Scroll instantly to next result in Find mode #4661 #4662
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Navigating between search results in find mode now respects the Vimium setting "Use smooth scrolling".
Description
This is a simple fix for #4661
In find mode until now the window.scrollTo() method was always called with hard-coded
behavior: "smooth"
. With this change it respects theSettings.smoothScroll
flag when jumping between search results.I've successfully tested the changes on...
Firefox Version 136.0.3 (64-bit) (Arch Linux)
and
Chromium Version 134.0.6998.165 (Official Build) Arch Linux (64-bit)
Off-Topic / vaguely related:
I checked the rest of the code base for occurrences of
"smooth"
and"instant"
and could only find one more hard-coded usage of"instant"
inscroller.js
in theperformScroll
function. It might be worth taking a look at that separate from this pull request, as I've noticed some other fairly "strange" behavior with that.vimium/content_scripts/scroller.js
Lines 66 to 77 in 1d0281f
The off topic strange behavior I've noticed was:
When using
d
to scroll down half a page, theperformScroll
function was triggered a total of 3 times with scrollamount
of1
,1
,1
,10
and359
pixels in my test case for some reason. I got different values depending on the page I tested it on, . So it might be worth investigating why it's triggering 5 scroll actions instead of just one. I suspect it has to do with scrollable elements somehow - I'm not very familiar with how the scroller is implemented in that regard. On Wikipedia about JavaScript I got 9x 1 pixel scrolls, a 17 pixel and a 344 pixel scroll. Triggering a total of 11scrollBy()
calls surely doesn't seem very efficient for a simpled
press. These tests were done on Firefox.I tested to implement the same logic to use
"smooth"
or"instant"
depending on theSettings.smoothScroll
flag as an experimental change, however using smooth scrolling in that context kinda broke the entire functionality, so that might be the reason why the"instant"
behavior is hard-coded in that code segment. I've only tested it withd
andu
functions, but since those were broken already I didn't bother testing any of the others for that experimental change.I ran into this issue with the experimental change on Chromium and didn't bother testing on Firefox for now, since it was off-topic anyway.
The experimental changes are obviously NOT part of this PR.