yairEO / fakescroll

vanilla-js lightweight custom HTML scrollbar
http://yaireo.github.io/fakescroll
GNU Affero General Public License v3.0
365 stars 33 forks source link

Scroll event #24

Closed loeffe1 closed 1 year ago

loeffe1 commented 1 year ago

Is there no event to allow scrolling or setting scrollRatio?

yairEO commented 1 year ago

What do you mean? "event to allow scrolling"?

fakescroll is only visually changes the scrollbar by replacing it with a fake one. it does not affect the scroll in any way. the real scrollbar is just hidden.

loeffe1 commented 1 year ago

This will scroll to the bottom of .my-div but will do nothing on the same element if fakescroll has been initialized on it

$('.my-div').animate({
    scrollTop: $('.my-div')[0].scrollHeight - $('.my-div')[0].clientHeight
}, 1000);
loeffe1 commented 1 year ago

I just realized I need to animate .fakeScroll__content

yairEO commented 1 year ago

Your code snippet is ancient. This is how things used to work 10+ years ago.

Use this to animate a scroll to the bottom:

$('.my-div')[0].scroll({
  top: 9999,
  behavior: 'smooth'
});

https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll

https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior