Hi, everyone. I already have website with GSAP animations and I'm trying to connect smooth-scroll library.
When I do it, smooth scroll working, but then doen't work ScrollTrigger and website height incorrect
This is my code
var Scrollbar = window.Scrollbar;
// Init Smooth Scrollbar
// ======================
Scrollbar.init(document.querySelector("#scroll-container"), {
damping: 0.05,
renderByPixel: true,
continuousScrolling: true,
alwaysShowTracks: true
});
// 3rd party library setup
// More info: https://greensock.com/docs/v3/Plugins/ScrollTrigger/static.scrollerProxy()
// ========================
let scrollPositionX = 0,
scrollPositionY = 0,
bodyScrollBar = Scrollbar.init(document.getElementById("scroll-container"));
bodyScrollBar.addListener(({ offset }) => {
scrollPositionX = offset.x;
scrollPositionY = offset.y;
});
bodyScrollBar.setPosition(0, 0);
bodyScrollBar.track.xAxis.element.remove();
// tell ScrollTrigger to use these proxy getter/setter methods for the "body" element:
ScrollTrigger.scrollerProxy("scroll-container", {
scrollTop(value) {
if (arguments.length) {
bodyScrollBar.scrollTop = value;
}
return bodyScrollBar.scrollTop;
}
});
// when smooth scroller updates, tell ScrollTrigger to update() too.
bodyScrollBar.addListener(ScrollTrigger.update);
And then I have height of page