Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Mamboleoo

Update scrollTrigger values

Recommended Posts

Hey there,

I have a ScrollTrigger animation with fixed start & end values
 

const tween = gsap.fromTo(el, {
    background: 'red'
}, {
    scrollTrigger: {
        scrub: true,
        start: 0,
        end: 500
    },
    background: 'blue',
    ease: 'none'
});

How can I update the end value on my side? Let's say after after the user opens a modal I need to update the end value to 100.

tween.scrollTrigger.end = 100; doesn't work as it is a read-only value.

 

I found the updateTomethod on GSAP 2.0 but it seems to have been removed on 3.0

Thanks!

Share this post


Link to post
Share on other sites

Hey @Mamboleoo,

 

Maybe this example will help you

 

start: () => start, // gets called on each refresh

 

See the Pen PoPjXPE by mikeK (@mikeK) on CodePen

 

Happy scrolling ...

Mikel

 

  • Like 4

Share this post


Link to post
Share on other sites

Assigning dynamic values with functions and calling update() could work indeed!

Thanks :)

  • Like 2

Share this post


Link to post
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.

×