npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sherifmagdy/animejs

v3.3.3

Published

JavaScript animation engine

Downloads

379

Readme

Getting started

Download

Via npm

$ npm install @sherifmagdy/animejs --save

Via yarn

$ yarn add @sherifmagdy/animejs

or manual download.

Usage

ES6 modules

import anime from '@sherifmagdy/animejs';

CommonJS

const { default: anime } = require('@sherifmagdy/animejs');

Classic ES5 file include

Link anime.browser.min.js in your HTML :

<script src="anime.browser.min.js"></script>
<script>
  const { default: anime } = anime;
</script>

Using a CDN

<script src="https://cdn.jsdelivr.net/npm/@sherifmagdy/animejs@latest/lib/anime.browser.min.js"></script>
<script>
  const { default: anime } = anime;
</script>

In case you are using modules in the browser:

<script type="module">
  import anime from 'https://cdn.jsdelivr.net/npm/@sherifmagdy/animejs@latest/lib/anime.esm.browser.min.js';

  //init
  const animeInstance = anime(...);
</script>

New Features (v3.3)

  • Improving timeline's add method to accept anime instance, timeline, function and instance parameters.
  • Add call method to the timeline.
  • Add kill method to anime instance and timeline.
  • Add speed method to anime instance and timeline.
  • restart, seek, play, pause, reverse, remove methods are now chainable in addition to speed and call methods.
  • Add a reversed instance or timeline to a normal timeline.
  • Add addMark() and removeMark() methods to the timeline.
  • seek() method and time offset parameter are now supporting adding a mark's name or a percentage of the duration as a string.
Sandbox demo to highlight the powerful of the new features here

new Methods (v3.3)

call ( callback :Function ) : self

Adds a callback to the timeline which gets executed at creation.

//simple example to show a 3d object in 3d space follows an empty helper

const 3dObject = { x: 1 , ...};
const 3dHelper = { x: 3 , ...};

const tl = anime
  .timeline({
    targets: 3dObject
  })
  .add({
    x: 3dHelper.x, // translate the 3dObject's x position to 3
  })
  .call(() => {
    3dHelper.x = 5; // then change the helper's x position to 5
  })
  .add({
    x: 3dHelper.x // translate the 3dObject's x position to 5
  });

  // we could NOT use begin or complete properties because the callback appended to them won't execute at creation of the timeline.

kill () :undefined

Kills the anime instance (or timeline), so that the instance is eligible for garbage collection.

const instance = anime({
  targets: '.class',
  translateX: '+=100',
  complete: (ins) => ins.kill(),
});

speed (multiplier :Number) :self

Controls the animation speed, where ( multiplier= 0.5 ) means half speed, ( multiplier= 2 ) double speed.

const instance = anime(...);

//Adjust the animation speed
instance.speed(2.5);

addMark (name :String) :self

Adds a mark at particular position in the timeline.

const instance = anime
  .timeline({
    targets: '#elementID',
  })
  .add({ translateY: 200 })
  .addMark('startScale')
  .add({ scaleX: 0.5 }, 'startScale')
  .add({ scaleY: 0.7 }, 'startScale');

removeMark (name :String) :self

Removes a predefined mark from the timeline.

const instance = anime
  .timeline({
    targets: '#elementID',
    complete: (tl) => tl.removeMark('startRotate'), // removes the mark after the animation complete
  })
  .add({ translateY: 200 })
  .addMark('startScale')
  .add({ scaleX: 0.5 }, 'startScale')
  .addMark('startRotate')
  .add({ rotateX: '50deg' }, 'startRotate');

Hello world

anime({
  targets: 'div',
  translateX: 250,
  rotate: '1turn',
  backgroundColor: '#FFF',
  duration: 800,
});

More Advanced Examples

add() method in the timeline

const instance = anime({
  targets: 'div',
  translateX: 250,
});

const tl = anime
  .timeline({
    targets: '.class',
  })
  .add({
    rotateZ: '2turn',
  })
  .add(instance); // adding an instance to the timeline

const anotherTl = anime
  .timeline({
    targets: '.anotherClass',
  })
  .add(tl) // adding a timeline to the another timeline
  .addMark('MARK')
  .add(() => {
    //do something in this particular time
  }) // adding a function to get executed in this position in the timeline
  .add(
    {
      scaleY: 0.4,
    },
    'MARK'
  );

//You can add a reversed animation to a normal timeline
const reversedTl = anotherTl.reverse();
const normalTl = anime.timeline(...).add(reversedTl); //can be useful in many cases

seek() method & time offset parameter

  const tl = anime
  .timeline(...)
  .add({ translateY : 200 })
  .addMark('scale')
  .add({scaleX : 1.2} , 'scale') // starts at the same time of the mark ('scale')
  .add({scaleY: 0.3} ,'scale'); // starts at the same time of the mark ('scale')

  tl.seek('scale'); // seek to a specefic position
  //OR
  tl.seek('32%') //Use a percentage

Documentation

Demos and examples

Browser support

| Chrome | Safari | IE / Edge | Firefox | Opera | | ------ | ------ | --------- | ------- | ----- | | 24+ | 8+ | 11+ | 32+ | 15+ |

Website | Documentation | Demos and examples | MIT License | © 2024 Sherif Magdy.