Element.scrollIntoView() method animation speed too slow in Chrome
Asked Answered
B

1

6

Is there any way to adjust Element.scrollIntoView() scrolling speed with defined transition animation as behavior: "smooth". Somehow, scrolling is too slow in Chrome, but fine in Firefox.

Bethea answered 26/3, 2019 at 8:16 Comment(4)
No, not with the standard method.Nicoline
@Nicoline does the same apply to window.scrollTo(). I mean, do they implement the same algos for animation?Bethea
Yes they do indeed.Nicoline
I'm building an app at the moment and have the same problem. It's fine in iOS also. Non-native scroll libraries are unfortunately so janky.Brynhild
O
3

The same thing happened to me and my problem came from the fact that I was calling Element.scrollIntoView() from within a "scroll" event-handler.
The thing is scrollIntoView() does trigger the scroll Event and so calling it within a scroll event handler creates an (almost) infinite loop.

Overboard answered 30/9, 2019 at 20:26 Comment(2)
What's the best way to solve this problem? (when you need to call scrollIntoView() from "scroll" event-handler)Ornithosis
What would be the point of scrollIntoView that's not on a scroll event? Just having some random content scrolling in on page load? Surely most people would have this on a scroll event, no?Truehearted

© 2022 - 2024 — McMap. All rights reserved.