-
Notifications
You must be signed in to change notification settings - Fork 0
/
Anime.js
49 lines (45 loc) · 1.25 KB
/
Anime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { ExtendableCSSEffect } from "@donkeyclip/motorcortex";
import anime from "mc-animejs-core/lib/anime.es.js";
export default class Anime extends ExtendableCSSEffect {
onGetContext() {
const options = {};
if (
Object.prototype.hasOwnProperty.call(
this.compoAttributes,
this.attributeKey
)
) {
const compoAttribute = this.compoAttributes[this.attributeKey];
for (let i = 0; i < compoAttribute.length; i++) {
if (
!Object.prototype.hasOwnProperty.call(
this.targetValue,
compoAttribute[i]
)
) {
continue;
}
options[compoAttribute[i]] = [
this.initialValue[compoAttribute[i]],
this.targetValue[compoAttribute[i]],
];
}
} else {
options[this.attributeKey] = [this.initialValue, this.targetValue];
}
this.target = anime({
autoplay: false,
duration: this.props.duration,
easing: "linear",
targets: this.element,
...((this.attrs || {}).attrs || {}),
...options,
}); // handle first render initial values
}
/**
* @param {number} f
*/
onProgress(m) {
return this.target.seek(this.target.duration * this.getFraction(m));
}
}