-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContent3.jsx
107 lines (104 loc) · 3.2 KB
/
Content3.jsx
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
import React from 'react';
import QueueAnim from 'rc-queue-anim';
import TweenOne from 'rc-tween-one';
import { Row, Col } from 'antd';
import OverPack from 'rc-scroll-anim/lib/ScrollOverPack';
class Content3 extends React.PureComponent {
getDelay = (e, b) => (e % b) * 100 + Math.floor(e / b) * 100 + b * 100;
render() {
const { ...props } = this.props;
const { dataSource, isMobile } = props;
delete props.dataSource;
delete props.isMobile;
let clearFloatNum = 0;
const children = dataSource.block.children.map((item, i) => {
const childObj = item.children;
const delay = isMobile ? i * 50 : this.getDelay(i, 24 / item.md);
const liAnim = {
opacity: 0,
type: 'from',
ease: 'easeOutQuad',
delay,
};
const childrenAnim = { ...liAnim, x: '+=10', delay: delay + 100 };
clearFloatNum += item.md;
clearFloatNum = clearFloatNum > 24 ? 0 : clearFloatNum;
return (
<TweenOne
component={Col}
animation={liAnim}
key={item.name}
{...item}
componentProps={{ md: item.md, xs: item.xs }}
className={
!clearFloatNum
? `${item.className || ''} clear-both`.trim()
: item.className
}
>
<TweenOne
animation={{
x: '-=10',
opacity: 0,
type: 'from',
ease: 'easeOutQuad',
}}
key="img"
{...childObj.icon}
>
<img src={childObj.icon.children} width="100%" alt="img" />
</TweenOne>
<div {...childObj.textWrapper}>
<TweenOne
key="h2"
animation={childrenAnim}
component="h2"
{...childObj.title}
>
{childObj.title.children}
</TweenOne>
<TweenOne
key="p"
animation={{ ...childrenAnim, delay: delay + 200 }}
component="div"
{...childObj.content}
>
{childObj.content.children}
</TweenOne>
</div>
</TweenOne>
);
});
return (
<div {...props} {...dataSource.wrapper}>
<div {...dataSource.page}>
<div {...dataSource.titleWrapper}>
{dataSource.titleWrapper.children.map((item, i) =>
React.createElement(
item.name.indexOf('title') === 0 ? 'h1' : 'div',
{ key: i.toString(), ...item },
typeof item.children === 'string' &&
item.children.match(
/\.(svg|gif|jpg|jpeg|png|JPG|PNG|GIF|JPEG)$/
)
? React.createElement('img', {
src: item.children,
alt: 'img',
})
: item.children
)
)}
</div>
<OverPack {...dataSource.OverPack}>
<QueueAnim key="u" type="bottom">
<Row key="row" {...dataSource.block}>
{children}
</Row>
</QueueAnim>
</OverPack>
</div>
</div>
);
}
}
export default Content3;