Jump to content
GreenSock

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

Killed GSDevTools forgets to clean its event listeners?

Recommended Posts

Hi,

 

after debugging my own even listeners cleanup using Chrome debug console, I noticed that GSDevTools, when killed, forget to clean its own event listeners. For example, in the image bellow I killed/recreated GSDevTools four times (to feed it with different timelines, as there is no functionality to do it without recreating the beast ^^). Are you aware of that? It's not a big deal for me right now though.

 

image.png.44c55d6fd90752bae6ccfd68736adc36.png

Link to comment
Share on other sites

Hm, are you sure you called kill() on all your instances? I see in the code that it removes the "keydown" event listener in .kill(). If you still think there's an issue, please provide a minimal demo and we'd be glad to take a peek. 

Link to comment
Share on other sites

 sensible code removed

 

That's the only code I'm allowed to share. I breakpoint on previousGSDevTools.kill() to check the console each time I change the timeline to display (so when I need to kill GSDevToolsprevious instance), thereby my screenshot above.

Link to comment
Share on other sites

Hm, I'm curious about a few things:

  1. Are you a Club GreenSock member under a different account or something? Or are you only using the trial version? I'm just confused about how you have access to it if your account shows you're not a member. 
  2. What version of GSDevTools are you using? Please make sure it's the latest. 
  3. Couldn't your code be simplified to this?: 
    let previousGSDevTools = GSDevTools.getById("AMjs_GSDevTools");
    let previousTime = globalTimeline.time();
    previousGSDevTools && previousGSDevTools.kill();
    GSDevTools.create({ id: "AMjs_GSDevTools", container: "#GSDevToolsContainer", animation: globalTimeline });
    gsap.delayedCall(0.2, () => globalTimeline.time(previousTime));

Like I said, in the file I'm looking at, the keydown event listener is indeed removed in the kill() method so I'm not entirely sure what to tell you. 🤷‍♂️

  • Like 1
Link to comment
Share on other sites

1. I'm an employee of a Belgian company which is a Club GreenSock member (I'll be glad to communicate you by private message any information you'd need if you want to check), and that's also why I don't have the permission to show more of my code.

2. GSDevTools 3.7.1

3. I like the "previousGSDevTools && previousGSDevTools.kill();". I'm ashame to admit it, but I was not aware that such a writting works on JS. Unfortunately, I may not simplify my code the way you suggest because my globalTimeline is not a "global" JS item ("global" here stands for "globalizing all the sub timelines"). As soon as the GSDevTools is created, I loose the reference of that globalTimeline. That's why I have to retrieve it from GSDevTools when I have to recreate the tools on a new globalTimeline.

 

Nevertheless, don't worry about this. As I wrote in my previous message, it's not a big deal at my side. Perhaps is it simply a side effect of using gsap inside React.

 

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