Skip to content

Instantly share code, notes, and snippets.

@floscr
Created May 17, 2016 08:13
Show Gist options
  • Save floscr/eff53d841920e3effc78547c73eb3861 to your computer and use it in GitHub Desktop.
Save floscr/eff53d841920e3effc78547c73eb3861 to your computer and use it in GitHub Desktop.
GSAP End Loop after X runs
var tl = new TimelineMax()
.from(myObj, 1, { /* ...values... */ }, 0) // Will play in every loop
.call(loopCheck) // End loop after X times
.from(myObj, 1, { /* ...values... */ }, 0) // Will not play on the last loop
.repeat(-1)
var loop = 0;
var loopMax = 3;
function loopCheck() {
loop++;
if (loop === loopMax) {
tl.pause();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment