-
-
Notifications
You must be signed in to change notification settings - Fork 238
/
Copy pathscroll-position.tsx
86 lines (83 loc) · 2.29 KB
/
scroll-position.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
import type { ScrollPosition } from '@/interface';
import React from 'react';
import '../../assets/index.less';
import type { TabsProps } from '../../src';
import Tabs from '../../src';
const items: TabsProps['items'] = [];
for (let i = 0; i < 50; i += 1) {
items.push({
key: String(i),
label: `Tab ${i}`,
children: `Content of ${i}`,
});
}
export default () => {
const [key, setKey] = React.useState('0');
const [scrollPosition, setScrollPosition] = React.useState<ScrollPosition>('end');
return (
<>
<div style={{ marginBottom: 10, display: 'flex', gap: 10 }}>
<label>
Start
<input
type="radio"
name="scrollPosition"
value="start"
checked={scrollPosition === 'start'}
onChange={e => setScrollPosition(e.target.value as ScrollPosition)}
/>
</label>
<label>
Center
<input
type="radio"
name="scrollPosition"
value="center"
checked={scrollPosition === 'center'}
onChange={e => setScrollPosition(e.target.value as ScrollPosition)}
/>
</label>
<label>
End
<input
type="radio"
name="scrollPosition"
value="end"
checked={scrollPosition === 'end'}
onChange={e => setScrollPosition(e.target.value as ScrollPosition)}
/>
</label>
<label>
Auto
<input
type="radio"
name="scrollPosition"
value="auto"
checked={scrollPosition === 'auto'}
onChange={e => setScrollPosition(e.target.value as ScrollPosition)}
/>
</label>
</div>
<div style={{ maxWidth: 550 }}>
<Tabs
activeKey={key}
onChange={curKey => setKey(curKey)}
defaultActiveKey="8"
items={items}
scrollPosition={scrollPosition}
/>
</div>
<div style={{ maxHeight: 550 }}>
<Tabs
style={{ height: 550 }}
activeKey={key}
onChange={curKey => setKey(curKey)}
defaultActiveKey="8"
items={items}
scrollPosition={scrollPosition}
tabPosition="left"
/>
</div>
</>
);
};