-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.tsx
67 lines (62 loc) · 1.95 KB
/
index.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
import { FC, HTMLAttributes } from 'react';
import * as style from './index.module.less';
export type HorizontalMarqueeProps = HTMLAttributes<HTMLDivElement> &
Partial<Record<'maxWidth' | 'duration' | 'height', string>>;
export const HorizontalMarquee: FC<HorizontalMarqueeProps> = ({
className = '',
children,
maxWidth = '100%',
duration,
height,
...props
}) => (
<div className={`overflow-hidden mw-100 ${className}`} {...props}>
<div
className={`d-inline-block align-top text-nowrap ${style.scrollWrap}`}
style={{
maxWidth,
animationDuration: duration,
height,
lineHeight: height
}}
>
<div
className={`d-inline-block ${style.scrollItem}`}
style={{ animationDuration: duration }}
>
{children}
</div>
</div>
</div>
);
export const HorizontalMarqueeBox: FC<HorizontalMarqueeProps> = ({
children,
maxWidth,
duration,
height
}) =>
height ? (
<div
className={`overflow-hidden ${style.scrollHeightWrap}`}
// @ts-expect-error remove after React 19 released
style={{ maxWidth: maxWidth, '--scroll-height': height }}
>
<div
className={`d-inline-block overflow-hidden mw-100 ${style.scrollContainer}`}
>
<div
className={`d-block overflow-hidden text-wrap text-break ${style.unScrollItem}`}
>
{children}
</div>
<HorizontalMarquee duration={duration}>
{children}
</HorizontalMarquee>
</div>
</div>
) : (
<HorizontalMarquee {...{ maxWidth, duration, height }}>
{children}
</HorizontalMarquee>
);
HorizontalMarquee.displayName = 'HorizontalMarquee';