ngx-slimscroll icon indicating copy to clipboard operation
ngx-slimscroll copied to clipboard

Scrollbar doesn't update correctly when firing 'scrollTo' event

Open riede opened this issue 6 years ago • 4 comments

It seams, that the scrollbar doesn't update correctly when using the SlimScrollEvent-Emitter with the type: 'scrollTo'. The content scrolls correctly (e.g. position y = 100) but the scrollbar stays on top. As soon as the scrollbar is moved just a little bit the content jumps back to top. Now, the content is based on the position of the scrollbar. Using the 'recalculate' event doesn't change anything.

riede avatar Oct 16 '18 12:10 riede

I noticed a similar kind of issue. lets says I have 50 elements of 20 pixels each. and my container is 100px. If I ask to scroll to the third item (scrollto (y: 60)) it will work. However if I ask to scroll to the 19th (scroll to y: 380) it just does not move.

sandorfr avatar Jan 10 '19 05:01 sandorfr

So to make it work I had to use something like : Math.Min(contentHeight - scrollviewHeight, elementHieght)

More concrete example:

new SlimScrollEvent({
          type: 'scrollTo',
          y: Math.min(y, 24 * this.dataSource.data.length - 300),
          easing: 'inOutQuint',
          duration: 500,
        }),

sandorfr avatar Jan 20 '19 23:01 sandorfr

thanks @sandorfr for solution. can you provide pull request with a fix maybe?

jkuri avatar Jan 21 '19 00:01 jkuri

thanks @sandorfr for solution. can you provide pull request with a fix maybe?

see #112

sandorfr avatar Jan 22 '19 02:01 sandorfr