Hi guys,
can you help me with this script?
I am using this codepen for horizontal scroll in a certain section:
this codepen for horizontal scroll
It works fine, however i'm already using this portion of code for smooth-scroll and adding this code breaks it:
//CSS
#viewport {overflow: hidden; position: fixed; height: 100%; width: 100%; top: 0; left: 0; right: 0; bottom: 0;}
#scroll-container { position: absolute; overflow: hidden; width: 100%;}
//Smooth Scroll
const container = document.querySelector("#scroll-container")
let height
function setHeight() {
height = container.clientHeight
document.body.style.height = height + "px"
}
ScrollTrigger.addEventListener("refreshInit", setHeight)
gsap.to(container, {
y: () => -(height - document.documentElement.clientHeight),
ease: "none",
scrollTrigger: {
trigger: document.body,
start: "top top",
end: "bottom bottom",
scrub: 0.8,
invalidateOnRefresh: true
}
});
Can you guys help me to fix it?
I would need them both to work.
Thanks!