/
SlowEnlargeTransitionChildView.js
107 lines (93 loc) · 2.47 KB
/
SlowEnlargeTransitionChildView.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
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
'use strict';
import TransitionChildView from './TransitionChildView';
import React, { Component } from 'react';
import {
View,
Animated,
Easing,
} from 'react-native';
export default class SlowEnlargeTransitionChildView extends TransitionChildView
{
constructor(props)
{
super(props);
this.initialize(props);
}
initialize(props)
{
var offsetX = (Math.random() * 200) - 100;
var offsetY = (Math.random() * 200) - 100;
this.state = {
left: new Animated.Value(offsetX),
right: new Animated.Value(-offsetX),
top: new Animated.Value(offsetY),
bottom: new Animated.Value(-offsetY),
opacity: new Animated.Value(0),
scale: new Animated.Value(0.75),
spinValue: new Animated.Value((Math.random() * 0.05) - 0.025),
};
}
refreshParameters(props, is_edit)
{
if (is_edit) {
if (props.is_showing) {
if (!this.props.is_showing) {
// show
Animated.parallel([
Animated.timing(this.state.opacity, {
toValue: 1,
duration: 1000,
}),
Animated.timing(this.state.left, {
toValue: 0,
duration: 3000,
}),
Animated.timing(this.state.right, {
toValue: 0,
duration: 3000,
}),
Animated.timing(this.state.top, {
toValue: 0,
duration: 3000,
}),
Animated.timing(this.state.bottom, {
toValue: 0,
duration: 3000,
}),
Animated.timing(this.state.scale, {
toValue: 1,
duration: 6000,
easing: Easing.inOut(Easing.quad),
}),
Animated.timing(this.state.spinValue, {
toValue: 0,
duration: 6000,
easing: Easing.inOut(Easing.quad),
}),
]).start((params) => {
var {finished} = params;
if (finished) {
this.onShown();
}
});
}
}
if (props.is_killing) {
if (!this.props.is_killing) {
// kill
Animated.parallel([
Animated.timing(this.state.opacity, {
toValue: 0,
duration: 1000,
}),
]).start((params) => {
var {finished} = params;
if (finished) {
this.onKilled();
}
});
}
}
}
}
}