1 | import { jsx } from '../../jsx';
|
2 | import { px } from '../../types';
|
3 | import Zoom, { ZoomProps } from '../zoom';
|
4 |
|
5 | export interface ScrollBarProps extends ZoomProps {
|
6 | |
7 |
|
8 |
|
9 | visible?: boolean;
|
10 | |
11 |
|
12 |
|
13 | position?: 'bottom' | 'top' | 'left' | 'right';
|
14 | |
15 |
|
16 |
|
17 | margin?: px;
|
18 | }
|
19 |
|
20 | export default (View) => {
|
21 | return class ScrollBar extends Zoom<ScrollBarProps> {
|
22 | willMount() {
|
23 | super.willMount();
|
24 | const { context, props } = this;
|
25 | const { visible, position = 'bottom', margin = '16px', chart } = props;
|
26 | const marginNumber = context.px2hd(margin);
|
27 |
|
28 | if (visible === false) {
|
29 | return null;
|
30 | }
|
31 |
|
32 | chart.updateCoordFor(this, {
|
33 | position,
|
34 | width: position === 'left' || position === 'right' ? marginNumber : 0,
|
35 | height: position === 'bottom' || position === 'top' ? marginNumber : 0,
|
36 | });
|
37 | }
|
38 |
|
39 | render() {
|
40 | const { props, state } = this;
|
41 | const { visible } = props;
|
42 | if (visible === false) {
|
43 | return null;
|
44 | }
|
45 | return <View position="bottom" {...props} {...state} />;
|
46 | }
|
47 | };
|
48 | };
|