1.1.7 • Published 5 years ago

npmpubsimpleone v1.1.7

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Animate Plus

Animate Plus is a JavaScript animation library focusing on performance and authoring flexibility. It aims to deliver a steady 60 FPS and weighs less than 3 KB (minified and compressed), making it particularly well-suited for mobile.

Getting started

npm install animateplus or download animateplus.js and start animating things:

import animate from "/animateplus.js";

animate({
  elements: "div",
  duration: 2000,
  delay: index => index * 100,
  transform: ["scale(0)", "scale(1)"]
})
.then(options => animate({
  ...options,
  transform: ["translate(0%)", "translate(500%)"]
}));

Preview this example

Options

elements

DefaultType
nullString | Element | NodeList | Array

Determines the DOM elements to animate. You can either pass it a CSS selector or DOM elements.

animate({
  elements: document.body.children,
  transform: ["rotate(0turn)", "rotate(1turn)"]
});

easing

DefaultType
out-elasticString

Determines the acceleration curve of your animation.

constantacceleratedecelerateaccelerate-decelerate
linearin-cubicout-cubicin-out-cubic
in-quarticout-quarticin-out-quartic
in-quinticout-quinticin-out-quintic
in-exponentialout-exponentialin-out-exponential
in-circularout-circularin-out-circular
in-elasticout-elasticin-out-elastic

The amplitude and period of elastic easings can be configured by providing space-separated values. Amplitude defaults to 1, period to 0.4.

// Increase elasticity
animate({
  elements: "span",
  easing: "out-elastic 1.4 0.2",
  transform: ["translate(0px)", "translate(500px)"]
});

duration

DefaultType
1000Number | Function

Determines the duration of your animation in milliseconds. By passing it a callback, you can define a different duration for each element. The callback takes the index of each element as its argument and returns a number.

// First element fades out in 1s, second element in 2s, etc.
animate({
  elements: "span",
  easing: "linear",
  duration: index => (index + 1) * 1000,
  opacity: [1, 0]
});

delay

DefaultType
0Number | Function

Determines the delay of your animation in milliseconds. By passing it a callback, you can define a different delay for each element. The callback takes the index of each element as its argument and returns a number.

// First element fades out after 1s, second element after 2s, etc.
animate({
  elements: "span",
  easing: "linear",
  delay: index => (index + 1) * 1000,
  opacity: [1, 0]
});
1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago