-
Notifications
You must be signed in to change notification settings - Fork 0
/
Content3.tsx
94 lines (87 loc) · 2.79 KB
/
Content3.tsx
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
import React, { useEffect, useState } 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';
import { getChildrenToRender, getDelay } from './utils';
import { BannerProps } from '../types';
const Content3: React.FC<BannerProps> = ({ dataSource, isMobile }) => {
const [clearFloatNum, setClearFloatNum] = useState(0);
useEffect(() => {
setClearFloatNum(0);
}, [dataSource]);
const blockChildren = dataSource.block.children;
const children = blockChildren.map((item: any, i: number) => {
const childObj = item.children;
const delay = isMobile ? i * 50 : getDelay(i, 24 / item.md);
const newClearFloatNum = (clearFloatNum + item.md) % 24;
const colClassName = !newClearFloatNum
? `${item.className || ''} clear-both`.trim()
: item.className;
return (
<TweenOne
component={Col}
animation={[
{ x: 0, y: "+=30", duration: 200, type: 'from', opacity: 0, delay: delay },
{ x: 0, y: 0, opacity: 1 },
]}
key={item.name}
{...item}
componentProps={{ md: item.md, xs: item.xs }}
className={colClassName}
>
<TweenOne
animation={[
{ x: 0, y: "+=30", duration: 200, type: 'from', opacity: 0, delay: delay },
{ x: 0, y: 0, opacity: 1 },
]}
key="img"
{...childObj.icon}
>
<img src={childObj.icon.children} width="100%" alt="img" />
</TweenOne>
<div {...childObj.textWrapper}>
<TweenOne
key="h2"
animation={[
{ x: 0, y: "+=30", duration: 200, type: 'from', opacity: 0, delay: delay },
{ x: 0, y: 0, opacity: 1 },
]}
component="h2"
{...childObj.title}
>
{childObj.title.children}
</TweenOne>
<TweenOne
key="p"
animation={[
{ x: 0, y: "+=30", duration: 200, type: 'from', opacity: 0, delay: 400 },
{ x: 0, y: 0, opacity: 1 },
]}
component="div"
{...childObj.content}
>
{childObj.content.children}
</TweenOne>
</div>
</TweenOne>
);
});
return (
<div {...dataSource.wrapper}>
<div {...dataSource.page}>
<div {...dataSource.titleWrapper}>
{dataSource.titleWrapper.children.map(getChildrenToRender)}
</div>
<OverPack {...dataSource.OverPack}>
<QueueAnim key="u" type="bottom">
<Row key="row" {...dataSource.block}>
{children}
</Row>
</QueueAnim>
</OverPack>
</div>
</div>
);
};
export default Content3;