I would like to have a smooth auto-scroll to a specific element in a Polymer 1.0 iron-list when I click on a button.
For now I have a simple auto scroll thanks to the scrollToIndex method.
But I would like to have a smooth animation, like the jQuery animation $("#list").animate({ scrollTop: 300 }, 2000);
, but without jQuery.
One of the big problem I encountered is that since iron-list don't display all the items at once, I cannot find the scrollTop position of a specific item because it is not yet in the DOM.
I started a JSFiddle here : http://jsfiddle.net/c52fakyf/2/
Thanks for any help!
I just learned animation through requestAnimationFrame, and I thought about this question. I made a simple animation method:
It's basically a recursive method that updates every time the screen refreshes. The method takes in a callback object with functions under the properties .start, .progress, and .done.
I modified your code a bit:
I got the easeInOut from Robert Penner's easing functions:
And violá:
http://jsfiddle.net/5uLhu6qa/
It's not exactly what you're asking for, but it's a start that you can continue with.