/
aniamte-queue.tsx
135 lines (119 loc) · 4.33 KB
/
aniamte-queue.tsx
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import React from 'react'
import { AnimateQueue } from '../../src/animate-queue'
import Button from '../../src/button'
const Animate = AnimateQueue.Item
const AnimateQueueGroup = AnimateQueue.Group
export default class Page extends React.Component {
state = {
animate1: true,
animate2: true,
animate3: true
}
componentDidMount() {
this.setState({ animate: true })
}
handleToggle = index => {
this.setState({ ['animate' + index]: !this.state['animate' + index] })
}
render() {
const { animate1, animate2, animate3 } = this.state
return (
<>
<h2>动画</h2>
<Animate animate={animate1}>
<p>我是一段会动的文字</p>
</Animate>
<Button style={{ marginTop: 20 }} onClick={() => this.handleToggle(1)}>切换动画</Button>
<h2>动画队列</h2>
<AnimateQueue animate={true}>
{[1,2,3,4,5,6,7,8].map(index => <p key={index}>我是一段会动的文字</p>)}
</AnimateQueue>
<h2>动画队列的间隔和速度</h2>
<AnimateQueue speed={2000} interval={200} animate={animate2}>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
</AnimateQueue>
<h2>动画的样式</h2>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<AnimateQueue
animate={animate2}
from={{ transform: 'translateX(-30px)' }}
to={{ transform: 'translateX(0px)' }}
>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
</AnimateQueue>
</div>
<div>
<AnimateQueue
animate={animate2}
from={{ transform: 'translateX(0px)' }}
to={{ transform: 'translateX(0px)' }}
>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
</AnimateQueue>
</div>
<div>
<AnimateQueue
animate={animate2}
from={{ transform: 'scale(1.4) translateY(-100px)' }}
to={{ transform: 'scale(1) translateY(0px)' }}
>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
</AnimateQueue>
</div>
<div>
<AnimateQueue
animate={animate2}
from={{ transform: 'scale(0)', }}
to={{ transform: 'scale(1)', }}
>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
</AnimateQueue>
</div>
</div>
<Button style={{ marginTop: 20 }} onClick={() => this.handleToggle(2)}>切换动画</Button>
<h2>动画队列分组依次执行</h2>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<AnimateQueueGroup animate={animate3}>
<AnimateQueue>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
</AnimateQueue>
<AnimateQueue>
<h2>我是标题</h2>
<p>我是一段会动的文字</p>
</AnimateQueue>
<AnimateQueue>
<h2>我是标题</h2>
<p>我是一段会动的文字</p>
</AnimateQueue>
<AnimateQueue>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
<p>我是一段会动的文字</p>
</AnimateQueue>
</AnimateQueueGroup>
</div>
<Button style={{ marginTop: 20 }} onClick={() => this.handleToggle(3)}>切换动画</Button>
</>
)
}
}