Perfect-scrollbar dispatches custom events.
container.addEventListener('ps-scroll-x', () => ...);
ps-scroll-yThis event fires when the y-axis is scrolled in either direction.
ps-scroll-xThis event fires when the x-axis is scrolled in either direction.
ps-scroll-upThis event fires when scrolling upwards.
ps-scroll-downThis event fires when scrolling downwards.
ps-scroll-leftThis event fires when scrolling to the left.
ps-scroll-rightThis event fires when scrolling to the right.
ps-y-reach-startThis event fires when scrolling reaches the start of the y-axis.
ps-y-reach-endThis event fires when scrolling reaches the end of the y-axis (useful for infinite scroll).
ps-x-reach-startThis event fires when scrolling reaches the start of the x-axis.
ps-x-reach-endThis event fires when scrolling reaches the end of the x-axis.
You can also watch the reach state via the reach property.
const ps = new
PerfectScrollbar(...);
console.log(ps.reach.x); // => 'start' or 'end' or null
console.log(ps.reach.y); // => 'start' or 'end' or null