googlearchive / core-list

Polymer virtualized list element
25 stars 23 forks source link

Position should be maintained when items are prepended to the list #73

Open bendavis78 opened 9 years ago

bendavis78 commented 9 years ago

When items are prepended to the list data, the position in the viewport jumps up, because scrollTop is not adjusted to compensate for the new scrollHeight.

LeonLiuY commented 9 years ago

I found exact same problem.

And I found a solution: https://github.com/Polymer/core-list/blob/master/core-list.html#L435

Changing this line to

if (idx > this._virtualStart) {

>= to > solved my problem.

But I'm not sure whether this change has any side effects.

LeonLiuY commented 9 years ago

Seem that the above solution is still not perfect.

The scrollTop is adjusted to, the top of the first visible element before new content is prepended.

That means if the first visible element is half-in the screen, the screen will change.