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