Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

begin() and complete() with loop: true on timelines are only called once #854

Open
manake opened this issue May 5, 2023 · 3 comments
Open
Assignees
Labels
Milestone

Comments

@manake
Copy link

manake commented May 5, 2023

begin() and complete() callbacks of timeline parts only get called once in the loop: true; mode, which is not correct.

let timeline = anime.timeline({
	loop: true,
	easing: 'linear',
});

timeline.add({
	duration: 500,
	complete: function(anim){
		// Only called once, not called on further loops.
	},
});
@juliangarnier juliangarnier self-assigned this May 6, 2023
@juliangarnier juliangarnier added this to the 4.0.0 milestone May 6, 2023
@juliangarnier
Copy link
Owner

It will be fixed in v4!

@ambienthack
Copy link

try this workaround:

let timeline = anime.timeline({
        //...
        loop: true,
        loopComplete: () => {
            timeline.restart();
        }
       //...
});

@VTY1999
Copy link

VTY1999 commented Oct 9, 2023

If you want to have a callback that runs only once at the end of the entire timeline (not on each loop), you can use the begin() callback for the timeline itself. Here's an example code:

let timeline = anime.timeline({
  loop: true,
  easing: 'linear',
  complete: function(anim) {
    // This callback will be called at the end of the entire timeline.
    console.log("Timeline complete");
  },
});

timeline.add({
  duration: 500,
  /* Your animation properties here */
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants