Table of Contents
- MotorCortex-Anime
- Intro / Features
- Getting Started
- Creating Incidents
- Adding Incidents in your clip
- Contributing
- License
- Sponsored by
Anime.js library as a MotorCortex CSS Layer.
The library exposes CSSEffect
which implementes an alternative CSS Layer for MotorCortex while the second (MotionPath
) performs motion path animation.
The Plugin exposes two Incidents:
CSSEffect
(CSS Layer implementation)MotionPath
Chrome | Safari | IE / Edge | Firefox | Opera |
---|---|---|---|---|
24+ | 6+ | 10+ | 32+ | 15+ |
$ npm install @donkeyclip/motorcortex-anime
# OR
$ yarn add @donkeyclip/motorcortex-anime
You can load Anime plugin in a two different ways, based on what you want to do with this plugin (you will find out more information below):
As a MotorCortex's core CSS Layer:
import { setCSSCore } from "@donkeyclip/motorcortex";
import AnimePluginDefinition from "@donkeyclip/motorcortex-anime";
setCSSCore(AnimePluginDefinition.CSSEffect);
As a simple plugin:
import { loadPlugin } from "@donkeyclip/motorcortex";
import AnimePluginDefinition from "@donkeyclip/motorcortex-anime";
const AnimePlugin = loadPlugin(AnimePluginDefinition);
Use the provided CSSEffect as the CSS core of MotorCortex.
const MyAnime = new CSSEffect({
animatedAttrs: {
left: '120px',
top: '220px',
background: 'orange',
width: '10px;
}
}, {
selector: '.a',
duration: 2000,
easing: 'linear'
});
Don't forget το import and load the Anime Plugin using the first way.
The MotioPath Incident implements the motion path capability of anime.js library. This feature allows motion of any element on any given (svg) path.
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.
For the MotionPath Incident you should import and load MotorCortex-Anime as a simple Plugin.
clipName.addIncident(incidentName, startTime);
In general, we follow the "fork-and-pull" Git workflow, so if you want to submit patches and additions you should follow the next steps:
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that we can review your changes