4.0.6

targets

css selector

dom node / nodelist

javascript object

{"charged":"0%","cycles":120}

array

properties

css properties

css transforms

object properties

{"prop1":0,"prop2":"0%"}

dom attributes

svg attributes

property parameters

duration

3000 ms

delay

1000 ms

end delay

1000 ms

easing

easeInOutExpo

round

0

specific property parameters

function based parameters

delay = 0 * 100
delay = 1 * 100
delay = 2 * 100

animation parameters

direction

normal
reverse
alternate

loop

normal 3 times
reverse 3 times
alternate 3 times
normal inifinite
inifinite reverse
inifinite alternate

autoplay

autoplay: true
autoplay: false

values

unitless

specific unit

relative

colors

HEX
RGB
HSL
RGBA
HSLA

from to

function based values

keyframes

animation keyframes

property keyframes

staggering

staggering basics

delay = (100 * 0) ms
delay = (100 * 1) ms
delay = (100 * 2) ms
delay = (100 * 3) ms
delay = (100 * 4) ms
delay = (100 * 5) ms

start value

delay = 500 + (100 * 0) ms
delay = 500 + (100 * 1) ms
delay = 500 + (100 * 2) ms
delay = 500 + (100 * 3) ms
delay = 500 + (100 * 4) ms
delay = 500 + (100 * 5) ms

range value

rotate = -360 + ((360 - (-360)) / 5) * 0
rotate = -360 + ((360 - (-360)) / 5) * 1
rotate = -360 + ((360 - (-360)) / 5) * 2
rotate = -360 + ((360 - (-360)) / 5) * 3
rotate = -360 + ((360 - (-360)) / 5) * 4
rotate = -360 + ((360 - (-360)) / 5) * 5

from value

direction

easing

grid

axis

timeline

timeline basics

time offsets

no offset
relative offset ('-=600')
absolute offset (400)

parameter inheritance

controls

play / pause

restart

reverse

seek

callbacks & promises

update

begin & complete

loopbegin & loopcomplete

change

changebegin & changecomplete

finished promise

svg

motion path

morphing

line drawing

easings

linear

penner's functions

cubic bézier curve

spring

elastic

steps

custom easing

react

useAeon

helpers

remove

get

set

random

tick

running

suspend on visibility change

css selector

Can be any CSS selector.

Pseudo elements can't be targeted using JavaScript.

TypeDefaultExample
Stringnulltargets: '.item'

Code example

aeon({
  targets: '.css-selector-demo .el',
  translateX: 250,
});

dom node / nodelist

Can be any DOM Node or NodeList.

TypeDefaultExample
DOM Nodenulltargets: el.querySelector('.item')
NodeListnulltargets: el.querySelectorAll('.item')

Code example

const elements = document.querySelectorAll('.dom-node-demo .el');

aeon({
  targets: elements,
  translateX: 270,
});

javascript object

A JavaScript Object with at least one property containing a numerical value.

TypeDefaultExample
Objectnulltargets: myObjectProp

Code example

const logEl = document.querySelector('.battery-log');

const battery = {
  charged: '0%',
  cycles: 120,
};

aeon({
  targets: battery,
  charged: '100%',
  cycles: 130,
  round: 1,
  easing: 'linear',
  update() {
    logEl.innerHTML = JSON.stringify(battery);
  },
});

array

An array containing multiple targets.

Accepts mixed types. E.g. ['.el', dom-node, jsObject]

TypeDefaultExample
Arraynulltargets: ['.item', el.getElementById('#thing')]

Code example

const el = document.querySelector('.mixed-array-demo .el-01');

aeon({
  targets: [el, '.mixed-array-demo .el-02', '.mixed-array-demo .el-03'],
  translateX: 250,
});

css properties

Any CSS properties can be animated.

Most CSS properties will cause layout changes or repaint, and will result in choppy animation. Prioritize opacity and CSS transforms as much as possible.

More details about accepted values in the values section.

Examplevalue
opacity.5
left'100px'

Code example

aeon({
  targets: '.css-prop-demo .el',
  left: '240px',
  backgroundColor: '#FFF',
  borderRadius: ['0%', '50%'],
  easing: 'easeInOutQuad',
});

css transforms

Animate CSS transforms properties individually.

It's possible to specify different timing for each transforms properties, more details in the specific property parameters section.

More details about accepted values in the values section.

Valid propertiesDefault unit
'translateX''px'
'translateY''px'
'translateZ''px'
'rotate''deg'
'rotateX''deg'
'rotateY''deg'
'rotateZ''deg'
'scale'
'scaleX'
'scaleY'
'scaleZ'
'skew''deg'
'skewX''deg'
'skewY''deg'
'perspective''px'

Code example

aeon({
  targets: '.css-transforms-demo .el',
  translateX: 250,
  scale: 2,
  rotate: '1turn',
});

object properties

Any Object property containing a numerical value can be animated.
More details about accepted values in the values section.

Examplevalue
prop150
'prop2''100%'

Code example

const objPropLogEl = document.querySelector('.js-object-log');

const myObject = {
  prop1: 0,
  prop2: '0%',
};

aeon({
  targets: myObject,
  prop1: 50,
  prop2: '100%',
  easing: 'linear',
  round: 1,
  update() {
    objPropLogEl.innerHTML = JSON.stringify(myObject);
  },
});

dom attributes

Any DOM Attributes containing a numerical value can be animated.
More details about accepted values in the values section.

Examplevalue
value1000
volume0
data-custom'3 dogs'

Code example

aeon({
  targets: '.dom-attribute-demo input',
  value: [0, 1000],
  round: 1,
  easing: 'easeInOutExpo',
});

svg attributes

Like any other DOM attributes, all SVG attributes containing at least one numerical value can be animated.
More details about accepted values in the values section and SVG animation in the SVG section.

Examplevalue
points'64 68.64 8.574 100 63.446 67.68 64 4 64.554 67.68 119.426 100'
scale1
baseFrequency0

Code example

aeon({
  targets: ['.svg-attributes-demo polygon', 'feTurbulence', 'feDisplacementMap'],
  points: '64 128 8.574 96 8.574 32 64 0 119.426 32 119.426 96',
  baseFrequency: 0,
  scale: 1,
  loop: true,
  direction: 'alternate',
  easing: 'easeInOutExpo',
});

duration

Defines the duration in milliseconds of the animation.

TypeDefaultExample
Number10003000
staggerSee staggering sectionstagger(150)
FunctionSee function based parameters section(el, i) => i * 150

Code example

aeon({
  targets: '.duration-demo .el',
  translateX: 250,
  duration: 3000,
});

delay

Defines the delay in milliseconds of the animation.

TypeDefaultExample
Number01000
staggerSee staggering sectionstagger(150)
FunctionSee function based parameters section(el, i) => i * 150

Code example

aeon({
  targets: '.delay-demo .el',
  translateX: 250,
  delay: 1000,
});

end delay

Adds some extra time in milliseconds at the end of the animation.

TypeDefaultExample
Number01000
staggerSee staggering sectionstagger(150)
FunctionSee function based parameters section(el, i) => i * 150

Code example

aeon({
  targets: '.endDelay-demo .el',
  translateX: 250,
  endDelay: 1000,
  direction: 'alternate',
});

easing

Defines the timing function of the animation.

Check out the easings section for a complete list of available easing and parameters.

TypeDefaultExample
String'easeOutElastic(1, .5)'easing: 'easeInOutQuad'

Code example

aeon({
  targets: '.easing-demo .el',
  translateX: 250,
  easing: 'easeInOutExpo',
});

round

Rounds up the value to x decimals.

TypeDefaultExample
Number0round: 10

Code example

const roundLogEl = document.querySelector('.round-log');

aeon({
  targets: roundLogEl,
  innerHTML: [0, 10000],
  easing: 'linear',
  round: 10, // Will round the animated value to 1 decimal
});

specific property parameters

Code example

aeon({
  targets: '.specific-prop-params-demo .el',
  translateX: {
    value: 250,
    duration: 800,
  },
  rotate: {
    value: 360,
    duration: 1800,
    easing: 'easeInOutSine',
  },
  scale: {
    value: 2,
    duration: 1600,
    delay: 800,
    easing: 'easeInOutQuart',
  },
  delay: 250, // All properties except 'scale' inherit 250ms delay
});

function based parameters

Get different values for every target and property of the animation.

The function accepts 3 arguments:

ArgumentsInfos
targetThe curent animated targeted element
indexThe index of the animated targeted element
targetsLengthThe total number of animated targets

See staggering section for easier values manipulation.

Code example

aeon({
  targets: '.function-based-params-demo .el',
  translateX: 270,
  direction: 'alternate',
  loop: true,
  delay(el, i) {
    return i * 100;
  },
  endDelay(el, i, l) {
    return (l - i) * 100;
  },
});

direction

Defines the direction of the animation.

AcceptsInfos
'normal'Animation progress goes from 0 to 100%
'reverse'Animation progress goes from 100% to 0%
'alternate'Animation progress goes from 0% to 100% then goes back to 0%

Code example

aeon({
  targets: '.dir-normal',
  translateX: 250,
  easing: 'easeInOutSine',
});

aeon({
  targets: '.dir-reverse',
  translateX: 250,
  direction: 'reverse',
  easing: 'easeInOutSine',
});

aeon({
  targets: '.dir-alternate',
  translateX: 250,
  direction: 'alternate',
  easing: 'easeInOutSine',
});

loop

Defines the number of iterations of your animation.

AcceptsInfos
NumberThe number of iterations
trueLoop indefinitely

Code example

aeon({
  targets: '.loop',
  translateX: 270,
  loop: 3,
  easing: 'easeInOutSine',
});

aeon({
  targets: '.loop-infinity',
  translateX: 270,
  loop: true,
  easing: 'easeInOutSine',
});

aeon({
  targets: '.loop-reverse',
  translateX: 270,
  loop: 3,
  direction: 'reverse',
  easing: 'easeInOutSine',
});

aeon({
  targets: '.loop-reverse-infinity',
  translateX: 270,
  direction: 'reverse',
  loop: true,
  easing: 'easeInOutSine',
});

aeon({
  targets: '.loop-alternate',
  translateX: 270,
  loop: 3,
  direction: 'alternate',
  easing: 'easeInOutSine',
});

aeon({
  targets: '.loop-alternate-infinity',
  translateX: 270,
  direction: 'alternate',
  loop: true,
  easing: 'easeInOutSine',
});

autoplay

Defines if the animation should automatically starts or not.

AcceptsInfos
trueAutomatically starts the animation
falseAnimation is paused by default

Code example

aeon({
  targets: '.autoplay-true',
  translateX: 250,
  autoplay: true,
  easing: 'easeInOutSine',
});

aeon({
  targets: '.autoplay-false',
  translateX: 250,
  autoplay: false,
  easing: 'easeInOutSine',
});

unitless

If the original value has a unit, it will be automatically added to the animated value.

TypeExample
NumbertranslateX: 250

Code example

aeon({
  targets: '.unitless-values-demo .el',
  translateX: 250, // -> '250px'
  rotate: 540, // -> '540deg'
});

specific unit

Forces the animation to use a certain unit and will automatically convert the initial target value.

Conversion accuracy can vary depending of the unit used.
You can also define the initial value of the animation directly using an array, see the from to values section.

TypeExample
Stringwidth: '100%'

Code example

const a = aeon({
  targets: '.specific-unit-values-demo .el',
  width: '100%', // from '28px' to '100%',
  easing: 'easeInOutQuad',
  direction: 'alternate',
  loop: true,
});

relative

Adds, substracts or multiplies the original value.

AcceptsEffectExample
'+='Add'+=100'
'-='Substract'-=2turn'
'*='Multiply'*=10'

Code example

const relativeEl = document.querySelector('.el.relative-values');
relativeEl.style.transform = 'translateX(100px)';

aeon({
  targets: '.el.relative-values',
  translateX: {
    value: '*=2.5', // 100px * 2.5 = '250px'
    duration: 1000,
  },
  width: {
    value: '-=20px', // 28 - 20 = '8px'
    duration: 1800,
    easing: 'easeInOutSine',
  },
  rotate: {
    value: '+=2turn', // 0 + 2 = '2turn'
    duration: 1800,
    easing: 'easeInOutSine',
  },
  direction: 'alternate',
});

colors

aeon.js accepts and converts Hexadecimal, RGB, RGBA, HSL, and HSLA color values.

CSS color codes ( e.g. : 'red', 'yellow', 'aqua' ) are not supported.

AcceptsExample
Hexadecimal'#FFF' or '#FFFFFF'
RGB'rgb(255, 255, 255)'
RGBA'rgba(255, 255, 255, .2)'
HSL'hsl(0, 100%, 100%)'
HSLA'hsla(0, 100%, 100%, .2)'

Code example

timeline({
  endDelay: 1000,
  easing: 'easeInOutQuad',
  direction: 'alternate',
  loop: true,
})
  .add({ targets: '.color-hex', background: '#FFF' }, 0)
  .add({ targets: '.color-rgb', background: 'rgb(255, 255, 255)' }, 0)
  .add({ targets: '.color-hsl', background: 'hsl(0, 100%, 100%)' }, 0)
  .add({ targets: '.color-rgba', background: 'rgba(255,255,255, 0.2)' }, 0)
  .add({ targets: '.color-hsla', background: 'hsla(0, 100%, 100%, 0.2)' }, 0)
  .add({ targets: '.colors-demo .el', translateX: 270 }, 0);

from to

Forces the animation to start at a specified value.

TypeExample
Array['50%', '100%']

Code example

aeon({
  targets: '.el.from-to-values',
  translateX: [100, 250], // from 100 to 250
  delay: 500,
  direction: 'alternate',
  loop: true,
});

function based values

Get different values for every target and property of the animation.

The function accepts 3 arguments:

ArgumentsInfos
targetThe curently animated targeted element
indexThe index of the animated targeted element
targetsLengthThe total number of animated targets

Code example

aeon({
  targets: '.function-based-values-demo .el',
  translateX(el) {
    return el.getAttribute('data-x');
  },
  translateY(el, i) {
    return 50 + (-50 * i);
  },
  scale(el, i, l) {
    return (l - i) + 0.25;
  },
  rotate() { return random(-360, 360); },
  borderRadius() { return ['50%', `${random(10, 35)}%`]; },
  duration() { return random(1200, 1800); },
  delay() { return random(0, 400); },
  direction: 'alternate',
  loop: true,
});

animation keyframes

Animation keyframes are defined using an Array, within the keyframes property.

If there is no duration specified inside the keyframes, each keyframe duration will be equal to the animation's total duration divided by the number of keyframes.

TypeExample
Array[ {value: 100, easing: 'easeOutExpo'}, {value: 200, delay: 500}, {value: 300, duration: 1000} ]

Code example

aeon({
  targets: '.animation-keyframes-demo .el',
  keyframes: [
    { translateY: -40 },
    { translateX: 250 },
    { translateY: 40 },
    { translateX: 0 },
    { translateY: 0 },
  ],
  duration: 4000,
  easing: 'easeOutElastic(1, .8)',
  loop: true,
});

property keyframes

Similar to animation keyframes, property keyframes are defined using an Array of property Object. Property keyframes allow overlapping animations since each property have its own keyframes array.

If there is no duration specified inside the keyframes, each keyframe duration will be equal to the animation's total duration divided by the number of keyframes.

TypeExample
Array[ {value: 100, easing: 'easeOutExpo'}, {value: 200, delay: 500}, {value: 300, duration: 1000} ]

Code example

aeon({
  targets: '.property-keyframes-demo .el',
  translateX: [
    { value: 250, duration: 1000, delay: 500 },
    { value: 0, duration: 1000, delay: 500 },
  ],
  translateY: [
    { value: -40, duration: 500 },
    { value: 40, duration: 500, delay: 1000 },
    { value: 0, duration: 500, delay: 1000 },
  ],
  scaleX: [
    { value: 4, duration: 100, delay: 500, easing: 'easeOutExpo' },
    { value: 1, duration: 900 },
    { value: 4, duration: 100, delay: 500, easing: 'easeOutExpo' },
    { value: 1, duration: 900 },
  ],
  scaleY: [
    { value: [1.75, 1], duration: 500 },
    { value: 2, duration: 50, delay: 1000, easing: 'easeOutExpo' },
    { value: 1, duration: 450 },
    { value: 1.75, duration: 50, delay: 1000, easing: 'easeOutExpo' },
    { value: 1, duration: 450 },
  ],
  easing: 'easeOutElastic(1, .8)',
  loop: true,
});

staggering basics

Staggering allows you to animate multiple elements with follow through and overlapping action.

stagger(value, options)
ArgumentsTypeInfoRequired
ValueNumber, String, ArrayThe manipulated value(s)Yes
OptionsObjectStagger parametersNo

Code example

aeon({
  targets: '.basic-staggering-demo .el',
  translateX: 270,
  delay: stagger(100), // increase delay by 100ms for each elements.
});

start value

Starts the staggering effect from a specific value.

stagger(value, {start: startValue})
TypesInfo
Number, StringSame as propety values, see values section

Code example

aeon({
  targets: '.staggering-start-value-demo .el',
  translateX: 270,
  delay: stagger(100, { start: 500 }), // delay starts at 500ms then increase by 100ms for each elements.
});

range value

Distributes evenly values between two numbers.

stagger([startValue, endValue])
TypeInfo
'easingName'All valid easing names are accepted, see easings section
function(i)Custom easing function, see custom easings section

Code example

aeon({
  targets: '.range-value-staggering-demo .el',
  translateX: 270,
  rotate: stagger([-360, 360]), // rotation will be distributed from -360deg to 360deg evenly between all elements
  easing: 'easeInOutQuad',
});

from value

Starts the stagger effect from a specific position.

stagger(value, {from: startingPosition})
OptionsTypeInfo
'first' (default)'string'Start the effect from the first element
'last''string'Start the effect from the last element
'center''string'Start the effect from the center
indexnumberStart the effect from the specified index

Code example

aeon({
  targets: '.staggering-from-demo .el',
  translateX: 270,
  delay: stagger(100, { from: 'center' }),
});

direction

Changes the order in which the stagger operates.

stagger(value, {direction: 'reverse'})
OptionsInfo
'normal' (default)Normal staggering, from the first element to the last
'reverse'Reversed staggering, from the last element to the first

Code example

aeon({
  targets: '.staggering-direction-demo .el',
  translateX: 270,
  delay: stagger(100, { direction: 'reverse' }),
});

easing

Stagger values using an easing function.

stagger(value, {easing: 'easingName'})
TypeInfo
'string'All valid easing names are accepted
function(i)Use your own custom easings function

Code example

aeon({
  targets: '.staggering-easing-demo .el',
  translateX: 270,
  delay: stagger(300, { easing: 'easeOutQuad' }),
});

grid

Staggering values based a 2D array that allow "ripple" effects.

stagger(value, {grid: [rows, columns]})
TypeInfo
arrayA 2 items array, the first value is the number of rows, the second the number of columns

Code example

aeon({
  targets: '.staggering-grid-demo .el',
  scale: [
    { value: 0.1, easing: 'easeOutSine', duration: 500 },
    { value: 1, easing: 'easeInOutQuad', duration: 1200 },
  ],
  delay: stagger(200, { grid: [14, 5], from: 'center' }),
});

axis

Forces the direction of a grid starrering effect.

stagger(value, {grid: [rows, columns], axis: 'x'})
ParametersInfo
'x'Follows the x axis
'y'Follows the y axis

Code example

aeon({
  targets: '.staggering-axis-grid-demo .el',
  translateX: stagger(10, { grid: [14, 5], from: 'center', axis: 'x' }),
  translateY: stagger(10, { grid: [14, 5], from: 'center', axis: 'y' }),
  rotateZ: stagger([0, 90], { grid: [14, 5], from: 'center', axis: 'x' }),
  delay: stagger(200, { grid: [14, 5], from: 'center' }),
  easing: 'easeInOutQuad',
});

timeline basics

Timelines let you synchronise multiple animations together.
By default each animation added to the timeline starts after the previous animation ends.

Creating a timeline:

const myTimeline = timeline(parameters);
ArgumentTypeInfoRequired
parametersObjectThe default parameters of the timeline inherited by childrenNo

Adding animations to a timeline:

myTimeline.add(parameters, offset);
ArgumentTypesInfoRequired
parametersObjectThe child animation parameters, override the timeline default parametersYes
time offsetString or NumberCheck out the Timeline offsets sectionNo

Code example

const els = document.querySelectorAll('.basic-timeline-demo .el');

// Create a timeline with default parameters
const tl = timeline({
  easing: 'easeOutExpo',
  duration: 750,
});

// Add children
tl
  .add({
    targets: els[0],
    translateX: 250,
  })
  .add({
    targets: els[1],
    translateX: 250,
  })
  .add({
    targets: els[2],
    translateX: 250,
  });

time offsets

Time offsets can be specified with a second optional parameter using the timeline .add() function. It defines when a animation starts in the timeline, if no offset is specifed, the animation will starts after the previous animation ends.
An offset can be relative to the last animation or absolute to the whole timeline.

TypeOffsetExampleInfos
String'+=''+=200'Starts 200ms after the previous animation ends
String'-=''-=200'Starts 200ms before the previous animation ends
NumberNumber100Starts at 100ms, reagardless of the animtion position in the timeline

Code example

const els = document.querySelectorAll('.offsets-demo .el');

// Create a timeline with default parameters
const tl = timeline({
  easing: 'easeOutExpo',
  duration: 750,
});

tl
  .add({
    targets: els[0],
    translateX: 250,
  })
  .add({
    targets: els[1],
    translateX: 250,
  }, '-=600') // relative offset
  .add({
    targets: els[2],
    translateX: 250,
  }, 400); // absolute offset

parameter inheritance

Parameters set in the parent timeline instance will be inherited by all the children.

Parameters that can be inherited
targets
duration
delay
endDelay
round

Code example

const tl = timeline({
  targets: '.params-inheritance-demo .el',
  delay(el, i) {
    return i * 200;
  },
  duration: 500,
  easing: 'easeOutExpo',
  direction: 'alternate',
  loop: true,
});

tl
  .add({
    translateX: 250,
    // override the easing parameter
    easing: 'spring',
  })
  .add({
    opacity: 0.5,
    scale: 2,
  })
  .add({
    // override the targets parameter
    targets: '.params-inheritance-demo .el.triangle',
    rotate: 180,
  })
  .add({
    translateX: 0,
    scale: 1,
  });

play / pause

Plays a paused animation, or starts the animation if the autoplay parameters is set to false.

animation.play();

Pauses a running animation.

animation.pause();

Code example

const animation = aeon({
  targets: '.play-pause-demo .el',
  translateX: 270,
  delay(el, i) { return i * 100; },
  direction: 'alternate',
  loop: true,
  autoplay: false,
  easing: 'easeInOutSine',
});

document.querySelector('.play-pause-demo .play').onclick = () => animation.play();
document.querySelector('.play-pause-demo .pause').onclick = () => animation.pause();

restart

Restarts an animation from its initial values.

animation.restart();

Code example

const animation = aeon({
  targets: '.restart-demo .el',
  translateX: 250,
  delay(el, i) { return i * 100; },
  direction: 'alternate',
  loop: true,
  easing: 'easeInOutSine'
});

document.querySelector('.restart-demo .restart').onclick = () => animation.restart();

reverse

Reverses the direction of an animation.

animation.reverse();

Code example

const animation = aeon({
  targets: '.reverse-anim-demo .el',
  translateX: 270,
  loop: true,
  delay(el, i) { return i * 200; },
  easing: 'easeInOutSine',
});

document.querySelector('.reverse-anim-demo .reverse').onclick = () => animation.reverse();

seek

Jump to a specific time (in milliseconds).

animation.seek(timeStamp);

Can also be used to control an animation while scrolling.

animation.seek((scrollPercent / 100) * animation.duration);

Code example

const animation = aeon({
  targets: '.seek-anim-demo .el',
  translateX: 270,
  delay(el, i) { return i * 100; },
  elasticity: 200,
  easing: 'easeInOutSine',
  autoplay: false,
  update(anim) {
    anim.pause();
  },
});

const seekProgressEl = document.querySelector('.seek-anim-demo .progress');
seekProgressEl.oninput = function() {
  animation.seek(animation.duration * (seekProgressEl.value / 100));
};

update

Callback triggered on every frame as soon as the animation starts playing.

TypeParametersInfo
FunctionanimationReturn the current animation Object

Code example

let updates = 0;

aeon({
  targets: '.update-demo .el',
  translateX: 270,
  delay: 1000,
  direction: 'alternate',
  loop: 3,
  easing: 'easeInOutCirc',
  update(anim) {
    updates++;
    progressLogEl.value = `progress : ${Math.round(anim.progress)}%`;
    updateLogEl.value = `updates : ${updates}`;
  },
});

begin & complete

begin() callback is triggered once, when the animation starts playing.

complete() callback is triggered once, when the animation is completed.

Both begin() and complete() callbacks are called if the animation's duration is 0.

TypeParametersInfo
FunctionanimationReturn the current animation Object

Code example

aeon({
  targets: '.begin-complete-demo .el',
  translateX: 240,
  delay: 1000,
  easing: 'easeInOutCirc',
  update(anim) {
    progressLogEl.value = `progress : ${Math.round(anim.progress)}%`;
    beginLogEl.value = `began : ${anim.began}`;
    completeLogEl.value = `completed : ${anim.completed}`;
  },
  begin(anim) {
    beginLogEl.value = `began : ${anim.began}`;
  },
  complete(anim) {
    completeLogEl.value = `completed : ${anim.completed}`;
  },
});

loopbegin & loopcomplete

loopBegin() callback is triggered once everytime a loop begin.

loopComplete() callback is triggered once everytime a loop is completed.

TypeParametersInfo
FunctionanimationReturn the current animation Object

Code example

let loopBegan = 0;
let loopCompleted = 0;

aeon({
  targets: '.loopBegin-loopComplete-demo .el',
  translateX: 240,
  loop: true,
  direction: 'alternate',
  easing: 'easeInOutCirc',
  loopBegin() {
    loopBegan++;
    beginLogEl.value = `loop began : ${loopBegan}`;
  },
  loopComplete() {
    loopCompleted++;
    completeLogEl.value = `loop completed : ${loopCompleted}`;
  },
});

change

Callback triggered on every frames in between the animation's delay and endDelay.

TypeParametersInfo
FunctionanimationReturn the current animation Object

Code example

let changes = 0;

aeon({
  targets: '.change-demo .el',
  translateX: 270,
  delay: 1000,
  endDelay: 1000,
  direction: 'alternate',
  loop: true,
  easing: 'easeInOutCirc',
  update(anim) {
    progressLogEl.value = `progress : ${Math.round(anim.progress)}%`;
  },
  change() {
    changeLogEl.value = `changes : ${changes++}`;
  },
});

changebegin & changecomplete

changeBegin() callback is triggered everytime the animation starts changing.

changeComplete() callback is triggered everytime the animation stops changing.

Animation direction will affect the order in which changeBegin() and changeComplete() are triggerd.

TypeParametersInfo
FunctionanimationReturn the current animation Object

Code example

let changeBegan = 0;
let changeCompleted = 0;

aeon({
  targets: '.changeBegin-changeComplete-demo .el',
  translateX: 240,
  delay: 1000,
  endDelay: 1000,
  loop: true,
  direction: 'alternate',
  easing: 'easeInOutCirc',
  update(anim) {
    progressLogEl.value = `progress : ${Math.round(anim.progress)}%`;
  },
  changeBegin() {
    beginLogEl.value = `change began : ${changeBegan++}`;
  },
  changeComplete() {
    completeLogEl.value = `change completed : ${changeCompleted++}`;
  },
});

finished promise

Every animation instances return a finished promise when the animation finised.

animation.finished.then(function() {
  // Do things...
});

Promises are not suported in IE %3C 11.

Code example

const logFinished = () => {
  set(finishedLogEl, { value: 'Promise resolved' });
  set(promiseEl, { backgroundColor: '#18FF92' });
};

const animation = timeline({
  targets: promiseEl,
  delay: 400,
  duration: 500,
  endDelay: 400,
  easing: 'easeInOutSine',
  update(anim) {
    progressLogEl.value = `progress : ${Math.round(anim.progress)}%`;
  },
})
  .add({ translateX: 250 })
  .add({ scale: 2 })
  .add({ translateX: 0 });

await animation.finished();
logFinished();

motion path

Animates an element relative to the x, y and angle values of an SVG path element.

const myPath = path('svg path');

The path function returns a new Function that returns the specified property.

Motion path animations are responsive since v3

ParametersExampleInfo
'x'myPath('x')Return the current x value in 'px' of the SVG path
'y'myPath('y')Return the current y value in 'px' of the SVG path
'angle'myPath('angle')Return the current angle value in 'degrees' of the SVG path

Code example

const p = path('.motion-path-demo path');

aeon({
  targets: '.motion-path-demo .el',
  translateX: p('x'),
  translateY: p('y'),
  rotate: p('angle'),
  easing: 'linear',
  duration: 2000,
  loop: true,
});

morphing

Creates transition between two svg shapes.

Shapes must have the same number of points!


More info on SVG shape morphing here.

Code example

aeon({
  targets: '.morphing-demo .polymorph',
  points: [
    { value: [
      '70 24 119.574 60.369 100.145 117.631 50.855 101.631 3.426 54.369',
      '70 41 118.574 59.369 111.145 132.631 60.855 84.631 20.426 60.369']
    },
    { value: '70 6 119.574 60.369 100.145 117.631 39.855 117.631 55.426 68.369' },
    { value: '70 57 136.574 54.369 89.145 100.631 28.855 132.631 38.426 64.369' },
    { value: '70 24 119.574 60.369 100.145 117.631 50.855 101.631 3.426 54.369' }
  ],
  easing: 'easeOutQuad',
  duration: 2000,
  loop: true,
});

line drawing

Creates path drawing animation using the 'stroke-dashoffset' property.
Set the path 'dash-offset' value with setDashoffset() in a from to formated value.

strokeDashoffset: [setDashoffset, 0]

More info on line drawing animation here.

Code example

aeon({
  targets: '.line-drawing-demo .lines path',
  strokeDashoffset: [setDashoffset, 0],
  easing: 'easeInOutSine',
  duration: 1500,
  delay(el, i) { return i * 250; },
  direction: 'alternate',
  loop: true,
});

linear

Does not apply any easing timing to your animation.
Usefull for opacity and colors transitions.

easing: 'linear'

Code example

aeon({
  targets: '.linear-easing-demo .el',
  translateX: 250,
  direction: 'alternate',
  loop: true,
  easing: 'linear',
});

penner's functions

Built-in Robert Penner's easing functions.

See easings in action on easings.net.

easing: 'easeInOutSine'

Availabe easings:

inoutin-outout-in
'easeInQuad''easeOutQuad''easeInOutQuad''easeOutInQuad'
'easeInCubic''easeOutCubic''easeInOutCubic''easeOutInCubic'
'easeInQuart''easeOutQuart''easeInOutQuart''easeOutInQuart'
'easeInQuint''easeOutQuint''easeInOutQuint''easeOutInQuint'
'easeInSine''easeOutSine''easeInOutSine''easeOutInSine'
'easeInExpo''easeOutExpo''easeInOutExpo''easeOutInExpo'
'easeInCirc''easeOutCirc''easeInOutCirc''easeOutInCirc'
'easeInBack''easeOutBack''easeInOutBack''easeOutInBack'
'easeInBounce''easeOutBounce''easeInOutBounce''easeOutInBounce'

Code example

[
  'easeInQuad',
  'easeInCubic',
  'easeInQuart',
  'easeInQuint',
  'easeInSine',
  'easeInExpo',
  'easeInCirc',
  'easeInBack',
  'easeOutQuad',
  'easeOutCubic',
  'easeOutQuart',
  'easeOutQuint',
  'easeOutSine',
  'easeOutExpo',
  'easeOutCirc',
  'easeOutBack',
  'easeInBounce',
  'easeInOutQuad',
  'easeInOutCubic',
  'easeInOutQuart',
  'easeInOutQuint',
  'easeInOutSine',
  'easeInOutExpo',
  'easeInOutCirc',
  'easeInOutBack',
  'easeInOutBounce',
  'easeOutBounce',
  'easeOutInQuad',
  'easeOutInCubic',
  'easeOutInQuart',
  'easeOutInQuint',
  'easeOutInSine',
  'easeOutInExpo',
  'easeOutInCirc',
  'easeOutInBack',
  'easeOutInBounce',
].forEach(function(easing) {
  const a = aeon({
    targets: `.penner-equations-demo .easing-${easing}`,
    translateY: [50, -50],
    direction: 'alternate',
    loop: true,
    delay: 100,
    endDelay: 100,
    duration: 1000,
    easing,
  });
});

cubic bézier curve

Use your own custom cubic Bézier curves cubicBezier(x1, y1, x2, y2).

easing: 'cubicBezier(.5, .05, .1, .3)'

You can use Bézier curves generator like Ceaser to generate your curves coordinates.

Code example

aeon({
  targets: '.cubic-bezier-demo .el',
  translateX: 250,
  direction: 'alternate',
  loop: true,
  easing: 'cubicBezier(.5, .05, .1, .3)',
});

spring

Spring physics based easing.

easing: 'spring(mass, stiffness, damping, velocity)'

The duration of a spring animation is defined by the spring parameters.
The animation duration parameter will not be taken into account.

ParameterDefaultMinMax
Mass10100
Stiffness1000100
Damping100100
Velocity00100

Code example

aeon({
  targets: '.spring-physics-demo .el',
  translateX: 250,
  direction: 'alternate',
  loop: true,
  easing: 'spring(1, 80, 10, 0)',
});

elastic

Elastic easing.

easing: 'easeOutElastic(amplitude, period)'
inoutin-outout-in
'easeInElastic''easeOutElastic''easeInOutElastic''easeOutInElastic'
ParameterDefaultMinMaxInfo
Amplitude1110Controls the overshoot of the curve. The larger this number, the more overshoot there is.
Period0.50.12Controls how many times the curve goes back and forth. The smaller this number, the more times the curtain goes back and forth.

Code example

aeon({
  targets: '.elastic-easing-demo > div:nth-of-type(1) .el',
  translateX: 270,
  easing: 'easeInElastic(1, 0.6)',
});

aeon({
  targets: '.elastic-easing-demo > div:nth-of-type(2) .el',
  translateX: 270,
  easing: 'easeOutElastic(1, 0.6)',
});

aeon({
  targets: '.elastic-easing-demo > div:nth-of-type(3) .el',
  translateX: 270,
  easing: 'easeInOutElastic(1, 0.6)',
});

aeon({
  targets: '.elastic-easing-demo > div:nth-of-type(4) .el',
  translateX: 270,
  easing: 'easeOutInElastic(1, 0.6)',
});

steps

Defines the number of jumps an animation takes to arrive at its end value.

easing: 'steps(numberOfSteps)'
ParameterDefaultMinMax
Number of steps101

Code example

aeon({
  targets: '.step-easing-demo .el',
  translateX: 250,
  direction: 'alternate',
  loop: true,
  easing: 'steps(5)',
});

custom easing

A custom easing function must be returned by function based value.

easing: function() { return function(time) { return time * i} }
ParameterInfo
TimeReturn the current time of the animation

Code example

aeon({
  targets: '.custom-easing-demo .el',
  translateX: 270,
  direction: 'alternate',
  loop: true,
  duration: 2000,
  easing(el, i, total) {
    return function(t) {
      return Math.pow(Math.sin(t * (i + 1)), total);
    };
  },
});

useAeon

A declarative way to use aeon in React.

Click the square in the demo to toggle the animation.

useAeon(config);

Code example

import { useAeon } from 'aeon/hooks';

const Component = ({ active }) => {
  const anim = useAeon({
    translateX: active ? 250 : 0,
  });

  return <div ref={ anim } />;
};

remove

Removes targets from a running animation or timeline.
The targets parameters accepts the same values as the targets property.

Removes targets from all active animations.

remove(targets);

Removes targets from a single animation or timeline.

animation.remove(targets);

Code example

const animation = aeon({
  targets: '.remove-demo .el',
  translateX: 270,
  direction: 'alternate',
  loop: true,
  easing: 'easeInOutQuad',
});

document.querySelector('.remove-el-button').addEventListener('click', function() {
  animation.remove('.remove-demo > div:nth-of-type(2) .el');
});

get

Returns the original value of an element.

get(target, propertyName, unit);

Since aeon uses getComputedStyle to access original CSS, the values are almost always returned in 'px', the third (optional) argument converts the value in the desired unit.

get(dom-node, 'width', 'rem');
ParameterTypeInfo
target'string', varAny valid targets can be used

CSS transforms: Only inlined values can be accessed.

Code example

const logEl = document.querySelector('.get-value-demo-log');
const el = document.querySelector('.get-value-demo .el');

logEl.innerHTML = `
  ".el" width is:<br>
  "${get(el, 'width', 'px')}" or "${get(el, 'width', 'rem')}rem";
`;

set

Immediately sets values to the specified targets.

set(targets, {property: value});
ParametersTypesInfo
target(s)'string', varAny valid targets can be used
valuesobjectAny valid properties can be used

Code example

set('.set-value-demo .el', {
  translateX() { return random(50, 250); },
  rotate() { return random(0, 360); },
});

random

Returns a random integer within a specific range.

random(minValue, maxValue);

Code example

const randomValues = function() {
  aeon({
    targets: '.random-demo .el',
    translateX() {
      return random(0, 270);
    },
    easing: 'easeInOutQuad',
    duration: 750,
    complete: randomValues,
  });
};

randomValues();

tick

Plays an animation using an external requestAnimationFrame loop.

animation.tick(time)

Don't forget to set the autoplay parameter to false to prevent the aeon built-in RAF loop to start.

Code example

const animation = aeon({
  targets: '.tick-demo .el',
  translateX: 270,
  direction: 'alternate',
  loop: true,
  easing: 'easeInOutQuad',
  autoplay: false,
});

const loop = t => {
  animation.tick(t);
  customRAF = requestAnimationFrame(loop);
};

requestAnimationFrame(loop);

running

Returns an Array of all active aeons instances currently running.

running

Code example

const runninLogEl = document.querySelector('.running-log');
const els = document.querySelectorAll('.running-demo .el');

aeon({
  targets: els[0],
  translateX: 270,
  direction: 'alternate',
  loop: true,
  easing: 'linear',
});

aeon({
  targets: els[1],
  translateX: 270,
  direction: 'alternate',
  loop: true,
  easing: 'easeInOutCirc',
});

aeon({
  targets: els[2],
  translateX: 270,
  direction: 'alternate',
  easing: 'easeInOutQuad',
  loop: true,
  update() {
    runninLogEl.innerHTML = `there are currently ${running.size} instances running`;
  },
});

suspend on visibility change

By default all animations are paused when switching tabs, useful if you want to make sure the user sees everything and doesn't miss an important part of your animation.
But you can choose to let the animation runs normally without any pause, like a video or an audio track that can continuously plays in the background.

Code example

const visibilitychangeLogEl = document.querySelector('.visibilitychange-log');

aeon({
  targets: '.visibilitychange-demo .el',
  translateX: 270,
  direction: 'alternate',
  easing: 'easeInOutQuad',
  loop: true,
  duration: 2000,
  update(a) {
    visibilitychangeLogEl.innerHTML = `animation progress ${Math.round(a.progress)}`;
  },
});