import Slider from '../index';
import Tooltip from '../../vc-tooltip';
import '../assets/index.less';
import '../../vc-tooltip/assets/bootstrap.less';
const { Handle } = Slider;
function log(value) {
console.log(value); //eslint-disable-line
}
const CustomizedSlider = {
data() {
return {
value: 50,
};
},
methods: {
onSliderChange(value) {
log(value);
this.value = value;
},
onAfterChange(value) {
log(value);
},
},
render() {
return (
);
},
};
const DynamicBounds = {
data() {
return {
min: 0,
max: 100,
};
},
methods: {
onSliderChange(value) {
log(value);
this.value = value;
},
onAfterChange(value) {
log(value);
},
onMinChange(e) {
this.min = +e.target.value || 0;
},
onMaxChange(e) {
this.max = +e.target.value || 100;
},
},
render() {
return (
);
},
};
const SliderWithTooltip = {
data() {
return {
visibles: [],
};
},
methods: {
handleTooltipVisibleChange(index, visible) {
this.visibles[index] = visible;
this.visibles = { ...this.visibles };
},
handleRange(h, { value, dragging, index, disabled, style, ...restProps }) {
const tipFormatter = value => `${value}%`;
const tipProps = { overlayClassName: 'foo' };
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),
visibleChange: log,
},
style: {
...handleStyleWithIndex,
},
};
return (
);
},
},
render() {
return ;
},
};
export default {
render() {
const style = { width: '400px', margin: '50px' };
const pStyle = { margin: '20px 0' };
return (
Basic Slider,`step=20, dots`
Basic Slider,`step=20, dots, dotStyle={"{borderColor: 'orange'}"}, activeDotStyle=
{"{borderColor: 'yellow'}"}`
Slider with tooltip, with custom `tipFormatter`
Slider with custom handle and track style.(old api, will be deprecated)
Slider with custom handle and track style.(The recommended new api)
Slider with dynamic `min` `max`
);
},
};