Creating Horizontal Scroll with GSAP ScrollTrigger in Next.js

Posted by

Next.js Horizontal Scroll With Gsap ScrollTrigger

.scroll-container {
width: 100%;
min-height: 100vh;
display: flex;
overflow-x: auto;
scroll-snap-type: x proximity;
}

.scroll-item {
flex: 0 0 auto;
width: 100vw;
height: 100vh;
scroll-snap-align: start;
}

Section 1
Section 2
Section 3
Section 4

gsap.registerPlugin(ScrollTrigger);

gsap.to(‘.scroll-item’, {
x: () => -(document.documentElement.offsetWidth – window.innerWidth) * (document.querySelector(‘.scroll-container’).scrollLeft / (document.querySelector(‘.scroll-container’).scrollWidth – document.documentElement.offsetWidth)),
ease: ‘none’,
scrollTrigger: {
trigger: ‘.scroll-container’,
start: ‘top top’,
end: ‘bottom bottom’,
scrub: 1
},
overwrite: ‘auto’
});

0 0 votes
Article Rating
22 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@darveterdarveter4511
6 months ago

4:52 "ES7+ React/Redux/React-Native and blah-blah-blah" 😂

@studyafa7159
6 months ago

What you have done after
Initialising useEffect
I dint understood a thing 😢😢

@asadullah7324
6 months ago

exactly I need. thank you

@CarlosEduardo42
6 months ago

This is great! Thank you!
But why end is "2000 top"? Why 2000 pixels? I don't underestand that.

@cptankit4208
6 months ago

Thnx man 🔥🫡

@philmour3465
6 months ago

amazing, you saved me <3

@FransGamingLow
6 months ago

Thank you very much

@Ghost-Stories710
6 months ago

Create more videos create GasP tutorial series

@TheProfessorMA
6 months ago

How to make Horizontal scroll and LocomotiveScroll using react ?

@XxbankerboomxX
6 months ago

How could i pin every section that comes into view?

@danielhiebeler1614
6 months ago

You are a hero!!

@owl_code
6 months ago

Hey
How fix the error when changing route with next js?

@miraj.
6 months ago

A BIIIIGGGGG Thank You 🙏 for this

@philippkretzschmar4653
6 months ago

Thanks a lot. Exactly what I was looking for.

@odia-sanatani
6 months ago

Thank you so much!

@jayasaikiran1761
6 months ago

Hey great tutorial, if possible make a video on while navigating to each page add a loader/page transition using Gsap in Nextjs 13

@erzhan6121
6 months ago

How to make this effect vertical

@SimPwear84
6 months ago

Simply amazing!! Short, sweet and straight to the point. You did an amazing job. Looking forward to more videos. Subbed!!

@maxblock5233
6 months ago

This is exactly what I needed, thank you so much!
Don't give up on the channel, there's more to come

@InSaneRoGer112003
6 months ago

over scrolling in mobile ??