Jump to content
Search Community

ScrollTrigger: .kill() or ”destroy” one specific ST-instance?

slebbo test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

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

  • Solution

 

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

 

  • Like 2
Link to comment
Share on other sites

  • 2 months later...
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

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