delay
Defines the default delay in milliseconds of all animated layout animations.
Compatible with the stagger() utility function.
Accepts
Number- Function based value that returns a
Numberequal to or greater than0
Default
0
delay code example
import { createLayout, utils, stagger } from 'animejs';
const [ $buttonA, $buttonB ] = utils.$('.controls button');
const layout = createLayout('.layout-container', {
delay: 500 // Delays the transition by 500ms
});
function animateLayout(delay) {
// You can override the layout delay in the update() method too
layout.update(({ root }) => root.classList.toggle('row'), { delay });
}
const animateWith500MsDelay = () => animateLayout();
const animateWithStaggerDelay = () => animateLayout(stagger(150));
$buttonA.addEventListener('click', animateWith500MsDelay);
$buttonB.addEventListener('click', animateWithStaggerDelay);
<div class="large layout centered row">
<div class="layout-container col grid-layout row">
<div class="item col">Item 1</div>
<div class="item col">Item 2</div>
<div class="item col">Item 3</div>
</div>
</div>
<div class="medium row">
<fieldset class="controls">
<button class="button">500 ms delay</button>
<button class="button">Staggered delay</button>
</fieldset>
</div>