Skip to content
Discussion options

You must be logged in to vote

@monolithMktg Good catch - I reproduced this with your Pen.

The stagger itself is working. The issue is that each child animation has no animatable property, so there is no tween to occupy the 500ms. As a result, onBegin and onComplete fire back-to-back at each staggered position.

For a class-only effect, timer children are a better fit:

import { createTimeline } from 'https://esm.sh/animejs';

const boxes = document.querySelectorAll('.box');
const animation = createTimeline({ autoplay: false });

boxes.forEach((el, index) => {
  animation.add(
    {
      duration: 500,
      onBegin: () => el.classList.add('active'),
      onComplete: () => el.classList.remove('active'),
    },
    index *

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@TargiX
Comment options

@monolithMktg
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@monolithMktg
Comment options

Answer selected by monolithMktg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants