-
Notifications
You must be signed in to change notification settings - Fork 0
/
RotatedTextReveal.js
94 lines (86 loc) · 2.16 KB
/
RotatedTextReveal.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { HTMLClip, CSSEffect } from "@donkeyclip/motorcortex";
export default class RotatedTextReveal 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 === " " ? " " : e
}</div>
`;
})
.join("");
return `
<div class="wrapper">
<div class="letter-wrapper">
${divList}
</div>
</div>
`;
}
get css() {
return `
.wrapper{
width:${this.attrs.width}px;
height: ${this.attrs.fontSize}px;
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;
transform: rotate(90deg);
transform-origin: bottom left;
text-transform:${this.attrs.textTransform};
}
.letter-wrapper{
width:${this.attrs.width}px;
height: ${this.attrs.fontSize}px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
`;
}
buildTree() {
const left = new CSSEffect(
{
animatedAttrs: {
transform: { rotate: "0deg" },
},
initialValues: {
transform: { rotate: "90deg" },
},
},
{
duration: 600,
selector: ".letter",
easing: "easeOutExpo",
delay: this.attrs.stagger ? `@stagger(${this.attrs.stagger})` : 0,
}
);
if (this.attrs.exitTime) {
const exit = new CSSEffect(
{
animatedAttrs: {
transform: { rotate: "90deg" },
},
},
{
duration: 600,
selector: ".letter",
easing: "easeOutExpo",
delay: this.attrs.stagger ? `@stagger(${this.attrs.stagger})` : 0,
}
);
this.addIncident(exit, this.attrs.exitTime || 1000);
}
this.addIncident(left, 0);
}
}