This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLayoutTransitionExample.js
122 lines (108 loc) · 3.68 KB
/
LayoutTransitionExample.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React from 'react';
import {LayoutTransitionGroup} from '../../src/index';
import SpringInterpolator from '../../src/interpolators/SpringInterpolator';
class LayoutTransitionExample extends LayoutTransitionGroup {
state = {
config: 0,
};
interpolator = new SpringInterpolator(180, 12, 0.1);
config = (i) => {
return () => {
this.beginTransition((prevState) => ({
config: i,
}), [this.barRef, this.listRef], 250, 'cubic-bezier(0.64, 0.13, 0.05, 1.67)');
};
};
getInterpolator = () => {
return this.interpolator;
}
render() {
const config = this.state.config;
const config1 = config === 0;
const config2 = config === 1;
const count = config1 ? 5 : config2 ? 6 : 7;
const gridStyle = {
height: '240px',
width: '100%',
maxWidth: '300px',
margin: '0 auto',
paddingTop: config1 ? '20px' : config2 ? '100px' : ' 200px',
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
flexGrow: '3',
};
const horizontalStyle = {
width: '100%',
height: '80px',
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
};
const barStyle = {
height: '80px',
};
const childStyle = (i) => ({
width: '48px',
height: '48px',
borderRadius: '50%',
backgroundColor: 'rgb(230, 150, 0)',
margin: '16px',
});
const buttonHolder = {
backgroundColor: 'rgb(150, 200, 230)',
height: '64px',
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
};
const buttonStyle = {
height: '48px',
flexGrow: '1',
margin: '8px',
backgroundColor: 'white',
border: '0',
};
const verticalFlex = {
height: '75%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
};
const pStyle = {
textAlign: 'center',
flexGrow: config1 ? 0 : config2 ? 2 : 4,
};
return (
<div>
<div style={buttonHolder}>
<button style={buttonStyle} onClick={this.config(0)}>0</button>
<button style={buttonStyle} onClick={this.config(1)}>1</button>
<button style={buttonStyle} onClick={this.config(2)}>2</button>
</div>
<div
style={horizontalStyle}
ref={(ref) => {
this.barRef = ref;
}}
>
<div style={{...barStyle, flexGrow: 1, backgroundColor: 'rgb(200, 0, 0)'}}></div>
<div style={{...barStyle, flexGrow: config1 ? 1 : config2 ? 5 : 1, backgroundColor: 'rgb(0, 200, 0)'}}></div>
<div style={{...barStyle, flexGrow: config1 ? 1 : config2 ? 5 : 10, backgroundColor: 'rgb(0, 0, 200)'}}></div>
</div>
<div
style={gridStyle}
ref={(ref) => {
this.listRef = ref;
}}
>
{[...Array(count).keys()].map((i) => <div style={childStyle(i)} key={i}></div>)}
</div>
</div>
);
}
}
export default LayoutTransitionExample;