forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollable.tsx
More file actions
63 lines (61 loc) · 1.43 KB
/
Scrollable.tsx
File metadata and controls
63 lines (61 loc) · 1.43 KB
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
import React from 'react';
import {
Container,
BaseTrackX,
BaseTrackY,
BaseThumbX,
BaseThumbY,
BaseWrapper,
BaseScroller,
} from './elements';
interface IScrollableProps {
TrackX?: React.ElementType;
TrackY?: React.ElementType;
ThumbX?: React.ElementType;
ThumbY?: React.ElementType;
Wrapper?: React.ElementType;
Scroller?: React.ElementType;
}
export const Scrollable: React.FC<IScrollableProps> = ({
TrackX = BaseTrackX,
TrackY = BaseTrackY,
ThumbX = BaseThumbX,
ThumbY = BaseThumbY,
Wrapper = BaseWrapper,
Scroller = BaseScroller,
...props
}) => (
<Container
{...props}
trackXProps={{
renderer: ({ elementRef, ...itemProps }) => (
<TrackX ref={elementRef} {...itemProps} />
),
}}
trackYProps={{
renderer: ({ elementRef, ...itemProps }) => (
<TrackY ref={elementRef} {...itemProps} />
),
}}
thumbXProps={{
renderer: ({ elementRef, ...itemProps }) => (
<ThumbX ref={elementRef} {...itemProps} />
),
}}
thumbYProps={{
renderer: ({ elementRef, ...itemProps }) => (
<ThumbY ref={elementRef} {...itemProps} />
),
}}
wrapperProps={{
renderer: ({ elementRef, ...itemProps }) => (
<Wrapper ref={elementRef} {...itemProps} />
),
}}
scrollerProps={{
renderer: ({ elementRef, ...itemProps }) => (
<Scroller ref={elementRef} {...itemProps} />
),
}}
/>
);