-
Notifications
You must be signed in to change notification settings - Fork 83
Consider adding a "behavior" option to scrollToIndex() #99
Comments
I tried "behavior" on the html spec page - open the devtools and paste this in the console to scroll to the last element smoothly: document.body.lastElementChild.scrollIntoView({behavior: 'smooth', 'block': 'end'}); It takes 25 seconds to scroll to the bottom - it will show ALL the content to the user, and slowly scroll to the desired element. If the element is closer to the current scroll position, it will arrive there faster. I think that's cool! The only way to implement it like that would be to gradually update the positions until reaching the desired index - basically compute the keyframes of that animation ourselves. |
Haha, wow, I'm glad you think that's cool. My first reaction was that it would be a bug in Chrome... It seems really unlikely that you'd actually want to wait 25 seconds to see your content? We should ask around, probably, before doing extra work to emulate that. Note that the spec for scrollIntoView() is not that helpful:
|
I like the Firefox behavior personally... |
Filed https://bugs.chromium.org/p/chromium/issues/detail?id=852549, we'll see what folks say. Still not sure what we should do in our case. |
I think that in either case we'd have to render intermediate content just for the sake of showing it while scrolling through it - otherwise we'd see the content we're leaving, a blank screen, and finally the element we wanted to scroll to. |
My thinking was we could render a bit of intermediate content at the beginning and at the end, but in the middle the animation would be going at "infinite speed" and skip past the stuff in between. Not sure if that's doable. |
Here a quick demo of how I'm afraid it would look like to just render beginning and end - http://jsbin.com/qusihoq/1/edit?html,output
|
If you try that in Firefox, it looks pretty reasonable, I think. Yeah, it'd be more perfect if all the text was there too, but it's OK. I wonder if there are native apps using their equivalent virtual scrollers that we should be checking out? Or web apps, for that matter. |
Closing this as this is related to the |
scrollIntoView() can take a
behavior
option, which is one of "auto", "instant", or "smooth". We should consider adding this to scrollToIndex() in the future, after #97 lands.The text was updated successfully, but these errors were encountered: