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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _extends from 'babel-runtime/helpers/extends';
import Slider from '../index';
import Tooltip from '../../vc-tooltip';
import '../assets/index.less';
import '../../vc-tooltip/assets/bootstrap.less';
var Handle = Slider.Handle;
var createSliderWithTooltip = Slider.createSliderWithTooltip;
var Range = createSliderWithTooltip(Slider.Range);
export default {
data: function data() {
return {
visibles: []
};
},
methods: {
handleTooltipVisibleChange: function handleTooltipVisibleChange(index, visible) {
this.visibles[index] = visible;
this.visibles = _extends({}, this.visibles);
}
},
render: function render() {
var h = arguments[0];
var handle = function handle(props) {
var value = props.value,
dragging = props.dragging,
index = props.index,
ref = props.ref,
style = props.style,
restProps = _objectWithoutProperties(props, ['value', 'dragging', 'index', 'ref', 'style']);
var handleProps = {
props: _extends({}, restProps, {
value: value
}),
key: index,
style: style,
ref: ref
};
return h(
Tooltip,
{
attrs: {
prefixCls: 'rc-slider-tooltip',
overlay: value,
visible: dragging,
placement: 'top'
},
key: index
},
[h(Handle, handleProps)]
);
};
// const handleRange = (h, { value, ref, dragging, index, disabled, style, ...restProps }) => {
// const tipFormatter = value => `${value}%`
// const tipProps = {}
// const {
// prefixCls = 'rc-slider-tooltip',
// overlay = tipFormatter(value),
// placement = 'top',
// visible = visible || false,
// ...restTooltipProps } = tipProps
// let handleStyleWithIndex
// if (Array.isArray(style)) {
// handleStyleWithIndex = style[index] || style[0]
// } else {
// handleStyleWithIndex = style
// }
// const tooltipProps = {
// props: {
// prefixCls,
// overlay,
// placement,
// visible: (!disabled && (this.visibles[index] || dragging)) || visible,
// ...restTooltipProps,
// },
// key: index,
// }
// const handleProps = {
// props: {
// value,
// ...restProps,
// },
// on: {
// mouseenter: () => this.handleTooltipVisibleChange(index, true),
// mouseleave: () => this.handleTooltipVisibleChange(index, false),
// },
// style: {
// ...handleStyleWithIndex,
// },
// ref,
// }
// return (
// <Tooltip
// {...tooltipProps}
// >
// <Handle
// {...handleProps}
// />
// </Tooltip>
// )
// }
var wrapperStyle = 'width: 400px; margin: 50px';
return h('div', [h(
'div',
{ style: wrapperStyle },
[h('p', ['Slider with custom handle']), h(Slider, {
attrs: { min: 0, max: 20, defaultValue: 3, handle: handle }
})]
), h(
'div',
{ style: wrapperStyle },
[h('p', ['Range with custom handle']), h(Range, {
attrs: { min: 0, max: 20, defaultValue: [3, 10], tipFormatter: function tipFormatter(value) {
return value + '%';
} }
})]
)]);
}
};