Jump to content
Search Community

onStart not working?

hmerscher 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

I am not able to get an onStart to work, though the onUpdate and onComplete work fine: These snippets are part of a larger vanilla javascript file. I want to know when this timeline starts and when it ends so I can update a DOM text element while the animation is running and remove the text once it is completed.

 

//onUpdate will also call the upDateCounter function and log "once" to the console (only repeatedly, versus one time for onComplete):

let tlWireframe = new TimelineMax({ onComplete: updateCounter }); 

function updateCounter() {
  console.log("once");
}

//The remainder of this code is just the multi-tween Timeline, 
tlWireframe
  .fromTo(
    ".wireframe-sitemap",
    3,
    { autoAlpha: 0, x: -900 },
    { autoAlpha: 1, x: 0, ease: Power2.easeOut, delay: 0.3 }
  )
  .to(".wireframe-sitemap", 3, {
    autoAlpha: 0,
    x: 1800,
    ease: Power2.easeIn,
    delay: 1
  })
  .fromTo(
    ".panel",
    3,
    { autoAlpha: 0, transform: "rotateY(-90deg)" },
    {
      autoAlpha: 1.25,
      transform: "rotateY(0deg)",
      ease: Power2.easeOut,
      delay: 0.5
    }
  )
  .fromTo(
    ".wireframe-swimlane",
    3,
    { autoAlpha: 0, x: -900 },
    { autoAlpha: 1, x: 0, ease: Power2.easeOut, delay: 0.3 },
    "-=1"
  )
  .to(".panel", 3, { autoAlpha: 0, transform: "rotateY(90deg)" }, "-=.25")
  .to(".wireframe-swimlane", 3, {
    autoAlpha: 0,
    x: 1800,
    ease: Power2.easeIn,
    delay: 1
  });

 

Link to comment
Share on other sites

Craig: Thank you! That was nice and stripped down and helpful. I forked your code and added a button "Click to Start". In my project my timeline(s) only start to play when a particular button is clicked. Anyway, with your code I was able to understand how to handle the callback functions to make it work for me. My test demo on codepen based on yours is here, just fyi. Thanks again, very helpful.

 

See the Pen mgKrYY by hmerscher (@hmerscher) on CodePen

  • Like 1
Link to comment
Share on other sites

  • 11 months later...

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