:rice: Interactive UI animation engine for the Web. Core renderer for Haiku Animator.
:rice: Interactive UI animation engine for the Web. Core renderer for Haiku Animator.
Animator Core is the runtime and rendering engine for Haiku Animator and the components you create with Animator. This engine is a dependency for any Haiku Animator components that are run on the web.
Note that for iOS and Android, Haiku Animator also supports exporting to Lottie. Animator Core is only used when rendering Animator components for the web.
Animator Core is compatible with all major modern web browsers: Firefox, Chrome, Safari, and Edge. Its footprint is ~50kB gzipped.
Animator Core provides a simple and familiar API for runtime manipulation of components that were built in Animator. You can play and pause animations, react to events, and even pass in dynamic data. (See the docs for more info.)
Creating an Animator component begins in Haiku Animator:
$ yarn global add @haiku/cli or $ npm i @haiku/cli --global$ haiku install @haiku/yourusername-yourcomponent$ haiku upgrade [projectname] [--version=rev]Dev tip: If you have Animator installed, you can also $ npm link or $ yarn link your Animator components to make them available to your codebase toolchain's hot reloading hooks. Animator projects live in ~/.haiku/projects.
If you want to install and develop with Animator Core directly, you can do so with:
$ npm install @haiku/core
Or via yarn:
$ yarn add @haiku/core
Animator Core is also available via Haiku's CDN:
For our full documentation (a work in progress), please see docs.haikuforteams.com. We welcome your contributions on Github.
Simple:
import AnimatorCore from "@haiku/core/dom";
const definition = {template: {elementName: 'div', children: ['Hello Animator!']}};
const factory = AnimatorCore(definition);
const component = factory(document.getElementById("mount"));
Animated:
import AnimatorCore from "@haiku/core/dom";
const definition = {
timelines: {
Default: {
"#box": {
"style.width": { 0: { value: "100px" }},
"style.height": { 0: { value: "100px" }},
"style.backgroundColor": { 0: { value: "red" }},
"rotation.z": {
0: { value: 0, curve: "linear" },
1000: { value: 3.14159 },
},
},
},
},
template: {
elementName: 'div',
attributes: {id: 'box'},
children: ['Hello Animation!'],
},
};
const factory = AnimatorCore(definition);
const component = factory(document.getElementById("mount"));
Interactive:
import AnimatorCore from "@haiku/core/dom";
const definition = {
options: {
autoplay: false,
},
states: {
clicks: {
value: 0,
},
},
eventHandlers: {
"#box": {
"click": {
handler: function () {
this.state.clicks += 1;
this.getTimeline("Default").play();
},
},
},
},
timelines: {
Default: {
"#box": {
"content": { 0: {
value: function (clicks) {
return clicks + "";
},
}},
"style.width": { 0: { value: "100px" }},
"style.height": { 0: { value: "100px" }},
"style.backgroundColor": { 0: { value: "red" }},
"rotation.z": {
0: { value: 0, curve: "linear" },
1000: { value: 3.14159 },
},
},
},
},
template: {
elementName: 'div',
attributes: {id: 'box'},
},
};
const factory = AnimatorCore(definition);
const component = factory(document.getElementById("mount"));
By default, Haiku tracks usage of published components by transmitting metadata to Haiku's Mixpanel account when components are initialized on the page. We send only public information: your component's name, its Haiku account username, the software version it was built with, and its share identifier.
To disable this, set the mixpanel option to false:
// ...
const factory = AnimatorCore(definition);
const component = factory(document.getElementById("mount"), {
mixpanel: false // Or the string of your own Mixpanel API token
})
Please use GitHub Issues.
Please send contributions via pull request.
Code improvements
Features
To develop Animator Core locally:
$ yarn installCompile with:
$ yarn compile
Test with:
$ yarn test
Find formatting problems with:
$ yarn lint
Run demos in your browser:
$ yarn demos
MIT. Please refer to LICENSE.txt. Copyright (c) 2016-2018 Haiku Systems Inc.
No open issues yet, or sync has not completed.