-
Notifications
You must be signed in to change notification settings - Fork 5
/
02-dialog-exit.js
69 lines (55 loc) 路 1.36 KB
/
02-dialog-exit.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
/* eslint-disable react/no-find-dom-node */
import React, { Component } from 'react'
import { findDOMNode } from 'react-dom'
import Velocity from 'velocity-animate'
import FakeDialog from './fake-dialog'
import Animated from './animated'
/*
*
*/
class Dialog extends Component {
animateAppear() {
const { slow } = this.props
const node = findDOMNode(this)
if (!node) {
return
}
const duration = slow ? 2000 : 600
Velocity(node, { scale: 0.3, opacity: 0, translateY: 0 }, { duration: 0 })
let promise = Velocity(
node,
{ scale: 1.0, opacity: 1 },
{ duration: duration, easing: [55, 7] }
)
promise.cancel = () => Velocity(node, 'stop')
return promise
}
animateExit() {
const { slow } = this.props
const node = findDOMNode(this)
if (!node) {
return
}
let promise = Velocity(
node,
{ translateY: 100, opacity: 0.0 },
{ duration: slow ? 2000 : 1000, easing: 'easeOutCubic' }
)
promise.cancel = () => Velocity(node, 'stop')
return promise
}
render() {
return <FakeDialog {...this.props} />
}
}
// Showcase
class DialogExit extends Component {
render() {
return (
<Animated onAnimationState={this.props.onAnimationState}>
{this.props.active && <Dialog {...this.props} />}
</Animated>
)
}
}
export default DialogExit