Jump to content
Search Community

onComplete "loop" not working

HyperNerd 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

Hello,

 

I had this idea to use onComplete on a delayed function to create kind of a looping effect, but it appears that once I call a function from onComplete more than once, it stops. I suppose my idea isn't possible this way?

 

function fadeOne() {
TweenLite.to(a1, 2, {css:{opacity:0},delay:4, ease:Expo.easeOut, onComplete:two});
}

function two() {
$("#a1").hide();
$("#b1").show();
var b1 = document.getElementById("b1");
TweenLite.from(b1, 2, {css:{opacity:0},delay:.5, ease:Expo.easeOut});
var b2 = document.getElementById("b2");
TweenLite.from(b2, 3, {css:{opacity:0,},delay:.7, ease:Expo.easeOut});
var b4 = document.getElementById("b4");
TweenLite.from(b4, 1, {css:{opacity:0, scale:0,left:"-440px"},delay:1.3, ease:Expo.easeOut, onComplete:fadeTwo});
}
function fadeTwo() {
TweenLite.to(b1, 2, {css:{opacity:0},delay:4, ease:Expo.easeOut, onComplete:one});
}
function one() {
$("#b1").hide();
$("#a1").show();
var a1 = document.getElementById("a1");
TweenLite.from(a1, 2, {css:{opacity:0},delay:.5, ease:Expo.easeOut});
var a2 = document.getElementById("a2");
TweenLite.from(a2, 3, {css:{opacity:0,},delay:.7, ease:Expo.easeOut});
var a4 = document.getElementById("a4");
TweenLite.from(a4, 1, {css:{opacity:0, scale:0,left:"-440px"},delay:1.3, ease:Expo.easeOut, onComplete:fadeOne});
}

Link to comment
Share on other sites

Thanks for the help, Jack! I tried this and the loop still stops once when I send it back to fadeOne again.

 

function fadeOne() {
TweenLite.to(a1, 2, {css:{opacity:0},delay:4, ease:Expo.easeOut, onComplete:two, onCompleteScope:this});
}

function two() {
$("#a1").hide();
$("#b1").show();
var b1 = document.getElementById("b1");
TweenLite.from(b1, 2, {css:{opacity:0},delay:.5, ease:Expo.easeOut});
var b2 = document.getElementById("b2");
TweenLite.from(b2, 3, {css:{opacity:0,},delay:.7, ease:Expo.easeOut});
var b4 = document.getElementById("b4");
TweenLite.from(b4, 1, {css:{opacity:0, scale:0,left:"-440px"},delay:1.3, ease:Expo.easeOut, onComplete:fadeTwo, onCompleteScope:this});
}
function fadeTwo() {
TweenLite.to(b1, 2, {css:{opacity:0},delay:4, ease:Expo.easeOut, onComplete:one, onCompleteScope:this});
}
function one() {
$("#b1").hide();
$("#a1").show();
var a1 = document.getElementById("a1");
TweenLite.from(a1, 2, {css:{opacity:0},delay:.5, ease:Expo.easeOut});
var a2 = document.getElementById("a2");
TweenLite.from(a2, 3, {css:{opacity:0,},delay:.7, ease:Expo.easeOut});
var a4 = document.getElementById("a4");
TweenLite.from(a4, 1, {css:{opacity:0, scale:0,left:"-440px"},delay:1.3, ease:Expo.easeOut, onComplete:fadeOne, onCompleteScope:this});
}

Link to comment
Share on other sites

Have you added console.log() calls inside each method to see if they're getting called and verifying that your targets are indeed what you expect to be passing each tween?

 

If you need more help, please create a simplified version that isolates the problem (rather than referring us to a page with lots of other stuff going on that could potentially be interfering).

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