Jump to content
GreenSock

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

Promises, deferreds and garbage collection

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

I was wondering if there is some kind of interaction happening that would prevent a deferred from being resolved in the onComplete event of TimelineLite? I have tried a bunch of things to get it to resolve, but it never does: passing in the object, having the deferred be a local variable in the outer scope, etc.

 

I am basically trying to create an animation that occurs before a route change in angular.js. There is a mechanism whereby I can create a deferred and the routing waits until it is either resolved or rejected. The problem is that while it works fine in a timeout callback, it doesn't work in an onComplete callback of TimelineLite. Can anyeone shed any light on why that would be? I can provide some code if you need it.

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

I can't say that I follow all that you are saying as I haven't used angular.js, but it sounds like a scope issue. Try assigning an onCompleteScope property inside your timeline's constructor

onCompleteScope : Object - Defines the scope of the onComplete function (what "this" refers to inside that function).

http://api.greensock.com/js/com/greensock/TimelineLite.html

 

var timeline = new TimelineLite({onComplete:someFunction, onCompleteScope:someObject});

 

If that doesn't work, yes, a very basic example would be great, preferably on codepen.io or jsfiddle.

 

Let us know if it works out for you or if you need more help.

Link to comment
Share on other sites

That was exactly it! You have no idea how many days I spent examining it and going over it piece-by-piece. If anyone else experiences this issue, you need to pass in $rootScope to onCompleteScope.

 

Thanks much! That is an amazing response and response time. 

  • Like 1
Link to comment
Share on other sites

Cool, very happy to hear it worked out for you.

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