slebbo Posted April 20, 2021 Share Posted April 20, 2021 I have a ScrollTrigger that I've created like this; let ST = ScrollTrigger.create({ ... In my usecase, I only want to diable/kill/destroy that specific instance. BUT — when I run; ST.kill(); this kills ALL of my other ScrollTriggers, globally. Is that intended behavior? If so, how can I just remove one instance? 🤔 Cheers! Link to comment Share on other sites More sharing options...
Solution akapowl Posted April 20, 2021 Solution Share Posted April 20, 2021 Hey there, @slebbo You could give your ScrollTrigger an ID ScrollTrigger.create({ ... id: 'this-trigger-id', ... }) and when wanting to kill that one special instance only, do it like so ScrollTrigger.getById("this-trigger-id").kill() Clicking the body will trigger the killing here See the Pen 1aaa44829a660a1fb77bc3139ec88af5 by akapowl (@akapowl) on CodePen 2 Link to comment Share on other sites More sharing options...
GreenSock Posted April 20, 2021 Share Posted April 20, 2021 6 hours ago, slebbo said: this kills ALL of my other ScrollTriggers, globally. That doesn't sound right - do you have a minimal demo showing this? @akapowl is correct about his suggestion. It just concerns me that you said killing one instance kills ALL instances, hence my request for a minimal demo. 1 Link to comment Share on other sites More sharing options...
slebbo Posted July 2, 2021 Author Share Posted July 2, 2021 On 4/20/2021 at 3:55 PM, akapowl said: You could give your ScrollTrigger an ID Sorry for not responding earlier — yes! this solved my problem! Link to comment Share on other sites More sharing options...
slebbo Posted July 2, 2021 Author Share Posted July 2, 2021 On 4/20/2021 at 9:10 PM, GreenSock said: That doesn't sound right - do you have a minimal demo showing this? @akapowl is correct about his suggestion. It just concerns me that you said killing one instance kills ALL instances, hence my request for a minimal demo. I was doing this with Laravel Mix (webpack) and AlpineJS. If it was unexpected behavior from GSAP's side, it was probably due to some other environmental related issue. How ever, the ID-solution did work out splendedly 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