Example #4 | Staggering




Staggering with Anime.js

Anime.js simplifies the process of implementing staggering effects with its intuitive API and comprehensive documentation. Let's explore how to use Anime.js for staggering animations:

    • const targets = '.stagger-demo .item';: This line defines the CSS selector for the elements to be animated. In this case, it targets elements with the class item inside an element with the class stagger-demo.
    • const animationProperties = { ... };: This object contains the properties for configuring the animation. It specifies how each element will be animated.
    • translateY: [-50, 0], opacity: [0, 1]: These properties define the starting and ending values for the translateY (vertical position) and opacity (transparency) of the elements.
    • easing: 'easeOutExpo': Sets the duration of the animation in milliseconds (1000ms = 1 second).
    • duration: 1000: Specifies the direction of the animation. In this case, it's set to alternate, causing the animation to alternate between forward and backward, creating a ping-pong effect.
    • delay: anime.stagger(100): This line introduces staggering by adding a delay to the start time of each animation. The anime.stagger() function generates a staggered delay based on the index of each target element multiplied by 100ms.

Staggering animations with Anime.js opens up a world of creative possibilities for enhancing your web projects. Experiment with different properties, timings, and easing functions to craft stunning animations that captivate your audience.