Jump to content
Search Community

Problems with goto label and play

Dennis Laupman test
Moderator Tag

Go to solution Solved by Diaco,

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

  • Solution

Hi dennislaupman  :)

 

try this :

var red = $("#red");
var tl = new TimelineMax({paused:true});
		tl.to(red, 1, {left:100}, "label1")
		  .addPause()
		  .to(red, 1, {rotation:360}, "label2")
		  .addPause()
		  .to(red, 1, {scale:.5}, "label3")
		  .addPause()
		  .to(red, 1, {backgroundColor:"green"}, "label4");

$('#nextLabel').on('click', function(){
    tl.play();
})
$('#label2').on('click', function(){
    tl.play("label2",false);
})

See the Pen WbbXML by MAW (@MAW) on CodePen

 

pls check this out :

http://greensock.com/docs/#/HTML5/GSAP/TimelineMax/play/

  • Like 1
Link to comment
Share on other sites

Hello Dennis.. Welcome to the GreenSock Forum

That second parameter is if you want events suppressed.

Checkout play() docs:

http://greensock.com/docs/#/HTML5/GSAP/TweenMax/play/
:

.play()
.play( from:*, suppressEvents:Boolean ) : *
Begins playing forward, optionally from a specific time (by default playback begins from wherever the playhead currently is).

Parameters:

from : *
(default = null) — The time (or label for TimelineLite/TimelineMax instances) from which the animation should begin playing (if none is defined, it will begin playing from wherever the playhead currently is).

suppressEvents : Boolean
(default = true) — If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the from parameter.

Returns : *
self (makes chaining easier)

:
:) I hope this helps

  • Like 1
Link to comment
Share on other sites

Nice example Diaco.AW :D

 

Dennis, you are correct.. the addPause() method is a special callback. So if you look at

See the Pen WbbXML by MAW (@MAW) on CodePen

.. and if you remove the second param (false) in the #label2 buttons event handler. You will see how it allows the special callback to be triggered.. in this case addPause(). So by using false in the second param it allows you to jump to that label ("label2") and trigger the rotation for that tween.

 

Here is a modified pen of Diaco.AW codepen example but with an extra button.

 

One suppresses events for label 2 and the other doesnt:

 

See the Pen QwwaKW by anon (@anon) on CodePen

 

To test:

  • Click Run in codepen . then click the second button called playLabel2 using false (suppressEvents)

To test again:

  • Click Run in codepen . then click the third button called playLabel2 using default true  (suppressEvents)

I hope this helps! :)

  • Like 2
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...