vue-infinite-loading icon indicating copy to clipboard operation
vue-infinite-loading copied to clipboard

Calling $state.complete at top direction scroll.

Open gigosa opened this issue 6 years ago • 2 comments

Thanks to your great work.

I'm using top direction scroll. When I call $state.complete() at the top of the list, scroll position will not come back to the previous place. The following is reproduction link. https://jsfiddle.net/n4p7ovm6/

I have a question that, does this plugin assumes to call $state.complete() only when the response data length of the API is 0?

I will also describe how I solved it.

this.$nextTick(() => {
  const target = document.documentElement;
  target.scrollTop = target.scrollHeight - target._infiniteScrollHeight + target.scrollTop;
});
$state.complete();

If this plugin assumes to call $state.complete() at any other times, I think it can be fixed by adding scrollBarStorage.restore(this.scrollParent); before this.$forceUpdate(). IMHO.

Thank you!

gigosa avatar May 30 '19 09:05 gigosa

@gigosa It is a bug, I will fix it in the next version, thanks a lot and glad you like it :D

PeachScript avatar Oct 23 '19 12:10 PeachScript

I wasn't able to see any problem in the JSFiddle shared by gigosa. However, I believe that the problem reported has to do with the problem I'm facing, which is:

If $state.complete() is called after the first set of items is added to the container, the scroll position stays at the top, as things were added at the bottom.

This JSFiddle illustrate this: https://jsfiddle.net/diogopedrosa/4p7yv8r3/1/

What I was expecting was to see the scroll knob at the bottom, with the items inserted at the top of the container.

diogocpedrosa avatar Sep 29 '20 13:09 diogocpedrosa