Jump to content
Search Community

ScrollTrigger snap issue

MrMateo7 test
Moderator Tag

Recommended Posts

Hi!

I'm having a an issue when scrollTrigger snaps. This is my code.

presST = gsap.timeline({
  scrollTrigger: {
    trigger: presElem,
    start: 'top top',
    end: '300% 90%',
    // markers: true,
    pin: true,
    pinSpacing: true,
    scrub: 1,
    toggleActions: "restart pause resume pause",
    snap: {
      snapTo: 1/7*6,
      duration: {min: 0.5, max: 1.25},
      ease: 'power1.out'
    }
  },
  defaults: {
    ease: 'power1.out',
  }
})

When the progress is less than 0.5, it snaps to progress 0, to the start. How avoid that? how to make aaaalways snaps to the specified point?

Link to comment
Share on other sites

If you want to customize how it behaves, you should use a function.

 

Quote
  • Function - snap: (value) => Math.round(value / 0.2) * 0.2 feeds the natural destination value (based on velocity) into the function and uses whatever is returned as the final progress value (in this case increments of 0.2), so you can run whatever logic you want. These values should always be between 0 and 1 indicating the progress of the animation, so 0.5 would be in the middle.

 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...