<script>
jQuery(document).ready(function($){
gsap.registerPlugin(ScrollTrigger);
ScrollTrigger.matchMedia({
"(min-width: 980px)": function(){
var allSections = $('.horizontal-section');
allSections.wrapAll('<div class="horizontal-container"/>');
gsap.to(allSections, {
xPercent: -100 * (allSections.length - 1),
ease: "none",
scrollTrigger: {
trigger: ".horizontal-container",
pin: true,
start: "top top",
scrub: 1,
snap: false,
// base vertical scrolling on how wide the container is so it feels more natural.
end: () => "+=" + document.querySelector(".horizontal-container").offsetWidth
}
});
}
})
});
</script>
This is the script that I'm using.