Jump to content
Search Community

Can I rely on onStart/onComplete inline function declared within a timelineMax.to()

Peter test
Moderator Tag

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'm still quite fresh with my js and just trying to work out if what I'm experiencing is a problem with my code, or whether it's a gsap bug, or it's not even supposed to work how I expected.

 

For example a part of my code that looks like the below, the following happens (as per console description):

 
var tl = new TimelineMax({onComplete:function(){
	console.log('I get called')
}})

tl.to($('#sectionWrapper'), 0.5, {scrollTo: {x: targetX}, onStart:function(){
	console.log('i also get called')
},
onComplete: function (){
	console.log('but i don\'t get called');
}});

I was expecting all console logs to happen... should they?

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

Very odd that callbacks wouldn't fire.

 

I made a little test that runs a timeline 200 times and has 3 callbacks per timeline just like yours:

See the Pen 0441d2c046957419b95410c6749aae14 by GreenSock (@GreenSock) on CodePen

 

It counts 600 callbacks firing.

 

I have also tested running 1000 times and it never failed, even on IE8 win7.

 

Can you give us more info to help us replicate the issue you are experiencing?

Link to comment
Share on other sites

Hi, thanks for the reply.

 

I'll need to clean my code up a bit (probable it was just a problem with my code) and then I'll see if I can replicate it and will let you know either way.

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