googlearchive / core-list

Polymer virtualized list element
25 stars 20 forks source link

detached -> attached = Scroll position lost #84

Open robrez opened 9 years ago

robrez commented 9 years ago

I'm using a core-list inside of core-pages.

The scroll position is lost if I switch to another page, then back to the page containing the core-list.

I do have a custom component wrapping the core-list element and I was able to workaround the issue like so:

detached: function() {
    this._saveFirstVisible = this.$.list._getFirstVisibleIndex();
}
domReady: function() {
    if(this._saveFirstVisible) {
        this.$.list.scrollToItem(this._saveFirstVisible);
        this._saveFirstVisible = 0;
    }
}

This seems to work but I'm really not sure if there's a chance that detached executes too late and getFirstVisibleIndex won't work... and I'm also not thinking it's a great idea for me to call a private function.

edit: saving off scrollTarget.scrollTop may be better