Skip to content
Permalink
Newer
Older
100644 122 lines (117 sloc) 2.74 KB
Aug 29, 2018
1
import React from 'react'
2
import { VelocityTransitionGroup , velocityHelpers } from 'velocity-react'
3
import 'velocity-animate/velocity.ui'
4
import animationTimings from './common/animationTimings'
5
6
const cardAnimationIn = velocityHelpers . registerEffect ( {
7
defaultDuration : animationTimings . cardEnter ,
8
calls : [
9
[
10
{
11
opacity : [ 1 , ] ,
12
translateY : [ , - 20 ] ,
13
translateZ :
14
} ,
15
1 ,
16
{
Aug 29, 2018
17
display : 'flex' ,
18
easing : 'spring'
19
}
20
]
21
]
22
} )
23
const cardAnimationOut = velocityHelpers . registerEffect ( {
24
defaultDuration : animationTimings . cardLeave ,
25
calls : [
26
[
27
{
28
opacity : [ , 1 ] ,
29
translateY : [ 20 , ] ,
30
translateZ :
31
} ,
32
1 ,
33
{
Aug 29, 2018
34
display : 'flex' ,
35
easing : 'spring'
36
}
37
]
38
]
39
} )
40
41
const gridAnimationIn = velocityHelpers . registerEffect ( {
42
defaultDuration : animationTimings . gridEnter ,
43
calls : [
44
[
45
{
46
opacity : [ 1 , ] ,
May 3, 2018
47
translateX : [ , - 1000 ] ,
48
translateZ :
49
} ,
50
1 ,
51
{
Aug 29, 2018
52
display : 'flex' ,
53
easing : 'spring'
54
}
55
]
56
]
57
} )
58
59
const gridAnimationOut = velocityHelpers . registerEffect ( {
60
defaultDuration : animationTimings . gridLeave ,
61
calls : [
62
[
63
{
May 3, 2018
64
opacity : [ 1 , ] ,
65
translateX : [ , 1000 ]
66
} ,
67
1 ,
68
{
Aug 29, 2018
69
display : 'flex' ,
70
easing : 'spring' ,
May 3, 2018
71
delay : 2000
72
}
73
]
74
]
75
} )
76
May 3, 2018
77
const TransitionGrid = ( { visible , items , removeItem } ) => {
78
return (
79
< VelocityTransitionGroup
80
enter = { { animation : gridAnimationIn } }
May 3, 2018
81
leave = { { animation : gridAnimationOut , delay : 500 } }
May 3, 2018
83
{ visible && (
84
< div className = "animated-grid" >
May 3, 2018
85
< VelocityTransitionGroup
86
component = "ul"
87
className = "grid"
88
runOnMount
89
enter = { {
90
animation : cardAnimationIn ,
91
stagger : animationTimings . cardStagger ,
92
drag : true ,
93
delay : animationTimings . gridEnter
94
} }
95
// velocity react is smart about applying the end stage of the leave animation
96
// (opacity : 0) to the enter animation
97
leave = { {
98
animation : cardAnimationOut ,
99
stagger : animationTimings . cardStagger ,
100
drag : true
101
} }
102
>
103
{ items . map ( item => {
104
return (
Aug 29, 2018
105
< div
106
className = "card"
107
key = { item }
108
onClick = { ( ) => removeItem ( item ) }
109
>
May 3, 2018
110
< div className = "close-card" > < / div >
111
< div > { item } < / div >
112
< / div >
113
)
114
} ) }
115
< / VelocityTransitionGroup >
116
< / div >
117
) }
118
< / VelocityTransitionGroup >
119
)
120
}
121
May 3, 2018
122
export default TransitionGrid

友情链: IM·体育网上直播_IM·体育赛事最新版_im体育官网在线官网在线 | im体育app平台下载|IM体育v2.3 安卓版|IM体育今天官网赛表 | im体育推荐官网_im体育今晚高清_im体育买软件 | 2022im体育网网址_分析观看比赛_2022im体育在线软件 | IM体育开户网址-Im体育官方网站-IM体育期胜负彩专家分析 | im电竞体育登录入口_IM·体育比分分析在线_IM·体育v8.5 IOS版 | im体育app官网下载|IM体育最新今天观看|IM体育赛事注册 |