-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTicker.js
More file actions
40 lines (38 loc) · 894 Bytes
/
Ticker.js
File metadata and controls
40 lines (38 loc) · 894 Bytes
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
import React from 'react';
import {TransitionMotion, spring} from 'react-motion';
export default function Ticker({item}) {
return (
<TransitionMotion
willEnter={() => ({
opacity: 0,
y: 15,
})}
willLeave={() => ({
opacity: spring(0),
y: spring(-15),
})}
styles={[{
key: item.id,
data: item,
style: {
opacity: spring(1),
y: spring(0),
},
}]}>
{(configs) =>
<div className="container">
{configs.map((config) =>
<div className="item"
key={config.key}
style={{
opacity: config.style.opacity,
transform: `translateY(${config.style.y}px)`,
}}>
{config.data.text}
</div>
)}
</div>
}
</TransitionMotion>
);
}