Jump to content
Search Community

Refresh scrolltrigger for one of them

fonveton test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

I have an animation on my page and Im trying to add another one. First animation works with scrolltrigger and changes heigh of some elements, that brokes start/end position for my second animation. When I refresh scrollTrigger before my second animation this time it brokes my first animations start/end position and can't reverse it on scroll. So my question is 'is there a way to refresh scrolltrigger for just one scrolltrigger animation' ?

Link to comment
Share on other sites

  • Solution

Hi,

 

You can use the refresh method that works for individual Scroll Trigger instances:

https://greensock.com/docs/v3/Plugins/ScrollTrigger/refresh()

 

const stOne = ScrollTrigger.create({/*...*/});
const stTwo = ScrollTrigger.create({/*...*/});
const stThree = ScrollTrigger.create({/*...*/});

// Add a new element to your HTML
addNewElement();

// Update a specific ScrollTrigger
stTwo.refresh();

The ScrollTrigger.refresh() method works for all the instances you have created.

 

If you keep running into an issue, please provide a minimal demo that clearly illustrates the problems you're having.

 

Happy Tweening!!!

  • Like 1
Link to comment
Share on other sites

This sounds very fishy to me - you should NOT have a situation where one ScrollTrigger is using old values (not refreshed) in order to work, and another one has fresh ones. They must be able to work together, fully refreshed. So it sounds like you have something wrong in your setup. It's impossible to know without seeing a minimal demo (like a CodePen). I would caution against doing what Rodrigo said even though it might technically work in one scenario (assuming you don't resize the page or do anything to trigger a full refresh() after that). At best, it's a band-aid but at worst it's just masking a fundamental problem in your setup. 

  • 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...