-
Notifications
You must be signed in to change notification settings - Fork 0
/
LetterScale.js
77 lines (70 loc) · 1.74 KB
/
LetterScale.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { HTMLClip, CSSEffect } from "@donkeyclip/motorcortex";
export default class LetterScale extends HTMLClip {
get html() {
this.list = this.attrs.text.split("");
const divList = this.list
.map((e, i) => {
return `<div class="letter letter-item-${i}">${e}</div>`;
})
.join("");
return `
<div class="wrapper">
<div class="letter-wrapper">
${divList}
</div>
</div>
`;
}
get css() {
const stroke =
this.attrs.stroke === true
? `-webkit-text-stroke:${this.attrs.strokeSize}px ${this.attrs.strokeColor};`
: ``;
return `
.wrapper{
width:${this.attrs.width}px;
height: ${this.attrs.height}px;
white-space: nowrap;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
.letter{
font-size:${this.attrs.fontSize}px;
color:${this.attrs.color};
text-transform:uppercase;
font-family: ${this.attrs.fontFamily};
position: relative;
${stroke}
}
.letter-wrapper{
width:${this.attrs.width}px;
height: ${this.attrs.height}px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
`;
}
buildTree() {
const left = new CSSEffect(
{
animatedAttrs: {
fontSize: `${this.attrs.fontSize}px`,
},
initialValues: {
fontSize: `${this.attrs.fontSize * 0.7}px`,
},
},
{
duration: 600,
selector: ".letter",
easing: "easeOutExpo",
delay: `@stagger(0, 600,0.5,linear,omni)`,
}
);
this.addIncident(left, 0);
}
}