goellner Posted February 25, 2021 Share Posted February 25, 2021 The snapping is not working as expected, I want it to snap to the nearest full screen section. The only point thats working is the third slide. See the Pen mdOpKxW by goellner (@goellner) on CodePen Link to comment Share on other sites More sharing options...
tailbreezy Posted February 25, 2021 Share Posted February 25, 2021 Hello goellner, Maybe this will help. gsap.registerPlugin(ScrollTrigger); const slides = [...document.querySelectorAll(".slide")]; ScrollTrigger.create({ trigger: ".slides", markers: true, start:'top top', snap: { snapTo: 1 / (slides.length), duration: { min: 0.2, max: 0.6 }, ease: "none" } }); 2 Link to comment Share on other sites More sharing options...
Solution akapowl Posted February 25, 2021 Solution Share Posted February 25, 2021 Hey @goellner It looks like snapTo: 1 / (slides.length + 1) works like you intend. See the Pen 6ff95c629e753916d4a913da8eb7cbdc by akapowl (@akapowl) on CodePen Is that better? Edit: Or set the start to 'top top' (which by default is 'top bottom' when the ScrollTrigger is not pinning) and use the slides.length like @tailbreezy suggested. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now