-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDemo5.js
59 lines (52 loc) · 1.44 KB
/
Demo5.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
import React, {Component} from 'react';
import {tween, ease} from 'react-imation';
import {Timeline} from 'react-imation/timeline';
import {Easer} from 'functional-easing';
const easeIn = ease(new Easer().using('in-cubic'));
const easeOut = ease(new Easer().using('out-cubic'));
const ballDiameter = 50;
const containerStyle = {
position: 'relative',
width: '100vw',
height: '100vh',
};
const ballContainerStyle = {
position: 'absolute',
left: '50%',
top: 'calc(100vh - 450px)',
width: ballDiameter,
transform: 'translate(-50%, -50%)'
}
export default class Demo5 extends Component {
render() {
return (
<div style={containerStyle}>
<div style={ballContainerStyle}>
<Timeline loop={true} min={0} max={100} playOnMount={true}>
{({tween:twn}) => {
const y = twn([
[0, easeIn(0)],
[50, easeOut(400)],
[100, 0],
]);
return <div
style={{
position: 'absolute',
borderRadius: '50%',
background: 'red',
width: ballDiameter,
height:
ballDiameter +
tween(y, [
[0, 0],
[370, 0],
[400, -40]
]),
transform: `translateY(${y}px)`
}} />
}}</Timeline>
</div>
</div>
)
}
}