Platinum sponsors

Function values

Values written as functions stay in your code.

A function-based value computes a value for each target. The editor shows it with the function type:

animate('.dot', {
  id: 'Dots spread',
  x: (el, i) => i * 80,
});

The editor plays the function, but you cannot edit it. On a property row of the Target folder, the type menu only offers delete, to remove the property. On the other rows, such as delay, the type menu is disabled.

The Anime.js editor zIndex row of a utils.set() call, with the function type

Keep values editable

Replace a function with a value the editor can edit:

Instead of Use
x: (el, i) => i * 80 x: stagger(80), see Stagger
delay: (el, i) => i * 100 delay: stagger(100)
rotate: () => Math.random() * 90 rotate: random({ min: 0, max: 90, perTarget: true }), see Random
A custom ease function cubicBezier(), linear(), spring() or a built-in ease such as 'out(3)'

When a function only reads a setting, move that setting into a named utils.set() call, and edit it in the Setters folder.

Previous
Next