ngx-slimscroll
ngx-slimscroll copied to clipboard
Scrollbar doesn't update correctly when firing 'scrollTo' event
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.
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.
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,
}),
thanks @sandorfr for solution. can you provide pull request with a fix maybe?
thanks @sandorfr for solution. can you provide pull request with a fix maybe?
see #112