Disabling smooth scrolling for `element.scroll({behavior: 'smooth'})` not possible




4 years ago
3 years ago


(Reporter: simon.lydell, Unassigned)



Firefox Tracking Flags

(Not tracked)




4 years ago
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0
Build ID: 20150117170720

Steps to reproduce:

1. Disable “Preferences > Advanced > General > Use smooth scrolling”. (The `general.smoothScroll` pref.)
2. Open any web page with a vertical scrollbar for the entire document. This page should work. (Resize the Firefox window to get a scrollbar if needed.)
3. Run `document.documentElement.scrollBy({top: 100, behavior: 'smooth'})` from the console.

Actual results:

The document was scrolled 100px down _smoothly_. 

Expected results:

The document should have been scrolled 100px down, but _instantly_.

Compare by scrolling the document with the mouse scroll wheel or the arrow keys: Since we disabled smooth scrolling in step 1 this is done instantly (no “smooth” effect).

I think it is important to let the _user_ choose the behavior, not the web page author. Why is there an option to disable smooth scrolling if it does not do so in all cases?

`element.scroll` and `element.scrollTo` are also affected, as well as the same methods on `window`. I think that passing `{behavior: 'smooth'}` should mean “it is ok to do this scroll smoothly”, not “always do this scroll smoothly”.


4 years ago
Component: Untriaged → Layout
Product: Firefox → Core
Component: Layout → DOM
Flags: needinfo?(kgilbert)
The current preference only affects smooth scrolling as a result of user events (Keyboard, Mouse Wheel, etc).

Would there be benefit in having a separate switch for disabling smooth scrolling that is a result of DOM methods that pass in {behavior: 'smooth'}, or would it be appropriate for the behavior of these scrolls to be tied to the existing "general.smoothScroll" switch?

Also, would this apply to CSS scroll snapping, when performing fling gestures on an OSX trackpad?
Flags: needinfo?(kgilbert)

Comment 2

4 years ago
It might make sense to have a separate switch, just like there are separate switches for smooth scrolling by pixels, lines, pages etc. Note that "general.smoothScroll" wins over those switches; it should win over the separate DOM method smooth scroll pref as well. It is important that if a user flips the "Smooth scrolling" switch in the preferences GUI _all_ smooth scrolling should be disabled. I like smooth scrolling myself, but on an older computer I had to turn it off because it was not smooth enough. It'd be a bummer if sites could force that janky scrolling. (Ok, they can anyway by using JavaScript, but hopefully custom smooth scrolling scripts will go away with time. Moreover, it is always possible to block (some) JavaScript.)
I just happened across this bug - note that you can disable the behavior:'smooth' scrolling by setting layout.css.scroll-behavior.enabled to false. Personally I don't think that general.smoothScroll should override the scroll-behavior CSS property or JS APIs, because if we're exposing it to web content then it should work as expected from their point of view. They might rely on the "interruptible" nature of smooth-scrolling, for example. Flipping an extra pref (layout.css.scroll-behavior.enabled) is something power users can do, but regular users probably won't do by accident.

Comment 4

3 years ago
Fair enough. I guess this can be closed then.

Thanks for letting me know about layout.css.scroll-behavior.enabled!
Last Resolved: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.