Skip to content
Permalink
7f5d791972
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
119 lines (114 sloc) 2.7 KB
import React from "react"
import PropTypes from "prop-types"
import { VelocityTransitionGroup , velocityHelpers } from "velocity-react"
import "velocity-animate/velocity.ui"
import animationTimings from "./common/animationTimings"
const cardAnimationIn = velocityHelpers . registerEffect ( {
defaultDuration : animationTimings . cardEnter ,
calls : [
[
{
opacity : [ 1 , ] ,
translateY : [ , - 20 ] ,
translateZ :
} ,
1 ,
{
display : "flex" ,
easing : "spring"
}
]
]
} )
const cardAnimationOut = velocityHelpers . registerEffect ( {
defaultDuration : animationTimings . cardLeave ,
calls : [
[
{
opacity : [ , 1 ] ,
translateY : [ 20 , ] ,
translateZ :
} ,
1 ,
{
display : "flex" ,
easing : "spring"
}
]
]
} )
const gridAnimationIn = velocityHelpers . registerEffect ( {
defaultDuration : animationTimings . gridEnter ,
calls : [
[
{
opacity : [ 1 , ] ,
translateX : [ , - 1000 ] ,
translateZ :
} ,
1 ,
{
display : "flex" ,
easing : "spring"
}
]
]
} )
const gridAnimationOut = velocityHelpers . registerEffect ( {
defaultDuration : animationTimings . gridLeave ,
calls : [
[
{
opacity : [ 1 , ] ,
translateX : [ , 1000 ]
} ,
1 ,
{
display : "flex" ,
easing : "spring" ,
delay : 2000
}
]
]
} )
const TransitionGrid = ( { visible , items , removeItem } ) => {
return (
< VelocityTransitionGroup
enter = { { animation : gridAnimationIn } }
leave = { { animation : gridAnimationOut , delay : 500 } }
>
{ visible && (
< div className = "animated-grid" >
< VelocityTransitionGroup
component = "ul"
className = "grid"
runOnMount
enter = { {
animation : cardAnimationIn ,
stagger : animationTimings . cardStagger ,
drag : true ,
delay : animationTimings . gridEnter
} }
// velocity react is smart about applying the end stage of the leave animation
// (opacity : 0) to the enter animation
leave = { {
animation : cardAnimationOut ,
stagger : animationTimings . cardStagger ,
drag : true
} }
>
{ items . map ( item => {
return (
< div className = "card" key = { item } onClick = { ( ) => removeItem ( item ) } >
< div className = "close-card" > < / div >
< div > { item } < / div >
< / div >
)
} ) }
< / VelocityTransitionGroup >
< / div >
) }
< / VelocityTransitionGroup >
)
}
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体育赛事注册 |