2.1.16 • Published 3 years ago

@kissmybutton/motorcortex-anime v2.1.16

Weekly downloads
769
License
MIT
Repository
github
Last release
3 years ago

MotorCortex Anime

Anime.js library as a MotorCortex Incident

Installation

$ npm install @kissmybutton/motorcortex-anime
# OR
$ yarn add @kissmybutton/motorcortex-anime
import Anime from "@kissmybutton/motorcortex-anime";

Key Concepts / Features

MotorCortex Anime takes the capabilities of Anime.js library and exposes them via easy to use MotorCortex Incidents. The library exposes two Incidents, the one with the name "Anime" which, by the use of the Anime.js engine, can perform any CSS (or any other attribute) animation to any selected element while the second performs motion path animation.

Browser compatibility

ChromeSafariIE / EdgeFirefoxOpera
24+6+10+32+15+

Documentation

Import and load the plugin to MotorCortex

import MotorCortex from "@kissmybutton/motorcortex";
import AnimePluginDefinition from "@kissmybutton/motorcortex-anime";

const AnimePlugin = MotorCortex.loadPlugin(AnimePluginDefinition);

Create an Anim animation Incident and place it anywhere in your Clip

import MotorCortex from "@kissmybutton/motorcortex";
import AnimePluginDefinition from "@kissmybutton/motorcortex-anime";

const AnimePlugin = MotorCortex.loadPlugin(AnimePluginDefinition);

const MyClip = new MotorCortex.Clip({
  html: `
    <div class="container">
      <div class="a"></div>
    </div>
  `,
  css: `
    .container{
      width: 600px;
      height: 400px;
      background: white;
      position: relative;
    }
    .a{
      width: 30px;
      height: 30px;
      position: absolute;
      background: red;
      top: 0px;
      left: 0px;
    }
  `
});

const MyAnime = new AnimePlugin.Anime({
  animatedAttrs: {
    left: '120px',
    top: '220px',
    background: 'orange',
    width: '10px;
  }
}, {
  selector: '.a',
  duration: 2000,
  easing: 'linear'
});

MyClip.addIncident(MyAnime, 1000);

MyClip.play();

Work with tranform

transform is (the only) composite attribute that Anime Incident can animate. Transform attribute includes the following attributes:

  • "translateX",
  • "translateY",
  • "translateZ",
  • "rotate",
  • "rotateX",
  • "rotateY",
  • "rotateZ",
  • "scale",
  • "scaleX",
  • "scaleY",
  • "scaleZ",
  • "skewX",
  • "skewY",
  • "perspective"

All of the attributes on this list can only be animated via the transform composite attribute:

const MyAnime = new AnimePlugin.Anime({
  animatedAttrs: {
    transform: {
      translateX: '50px',
      scale: 2
    }
  }
}, {
  selector: '.a',
  duration: 2000,
  easing: 'linear'
});

MotionPath

The MotioPath Incident implements the motion path capability of anime.js library. This feature allows motion of any element on any given (svg) path.

Create a MotionPath animation Incident and place it anywhere in your Clip

The syntax is simple:

const motionPath = new AnimePlugin.MotionPath({
  pixelsAccuracy: 5,
  animatedAttrs: {
    positionOn: {
      pathElement: 'the selector that targets your path element'
    }
  }
}, {
  selector: '.a',
  duration: 2000,
  easing: 'linear'
});

As you can notice the animated attribute here is positionOn which in turn is an object expecting only one key, the pathElement which is a selctor to the path element that defines the motion path.

The selected elements will sleep into this path on the given duration.

One more thing to notice is the pixelsAccuracy attribute. This attribute sets the distance threshold between two sequential points of the path that the element should move. This attribute can be used so the motion path effect gets more performant (less processing is required). The default value is 4.

Exposed Incidents

  • Anime
  • MotionPath

Demo

https://kissmybutton.github.io/motorcortex-anime/demo/

License

MIT License

Kiss My Button

2.1.16

3 years ago

2.1.15

3 years ago

2.1.14

3 years ago

2.1.13

3 years ago

2.1.12

3 years ago

2.1.10

3 years ago

2.1.11

3 years ago

2.1.9

3 years ago

2.1.8

3 years ago

2.1.6

3 years ago

2.1.7

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.4.15

4 years ago

1.4.14

4 years ago

1.4.13

4 years ago

1.4.12

4 years ago

1.4.11

4 years ago

1.4.10

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.2.9

4 years ago

1.2.8

5 years ago

1.3.0

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

0.7.4

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago