<section class="h-100vh content-center">
HOME
</section>
<div class="container">
<section class="slider lightgreen content-center">A</section>
<section class="slider lightblue content-center">B</section>
<section class="slider pink content-center">C</section>
<section class="slider orange content-center">D</section>
<section class="slider yellow content-center">E</section>
</div>
<section class="h-100vh content-center">
THE END
</section>
* {
margin: 0;
padding: 0;
list-style: none;
}
.container {
height: 100vh;
position: relative;
display: flex;
width: 500vw;
}
.content-center {
display: flex;
align-items: center;
justify-content: center;
}
.h-100vh {
height: 100vh;
}
section {
width: 100%;
}
.lightgreen {
background: lightgreen;
}
.lightblue {
background: lightblue;
}
.pink {
background: pink;
}
.orange {
background: orange;
}
.yellow {
background: yellow;
}
// const allSlider = gsap.utils.toArray('.slider')
const allSlider = document.querySelectorAll('.slider')
gsap.to('.slider', {
xPercent: -100 * ( allSlider.length -1 ),
ease: 'none',
scrollTrigger: {
markers: true,
trigger: '.container',
scrub: 1,
pin: true,
snap: 1 / ( allSlider.length -1 ),
end: () => `+=${document.querySelector('.container').offsetWidth}`
}
})
This Pen doesn't use any external CSS resources.