You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
var vue = require('vue');
|
|
var error = require('../../../utils/error.js');
|
|
|
|
const useStops = (props, initData, minValue, maxValue) => {
|
|
const stops = vue.computed(() => {
|
|
if (!props.showStops || props.min > props.max)
|
|
return [];
|
|
if (props.step === 0) {
|
|
error.debugWarn("Slider", "step should not be 0.");
|
|
return [];
|
|
}
|
|
const stopCount = (props.max - props.min) / props.step;
|
|
const stepWidth = 100 * props.step / (props.max - props.min);
|
|
const result = Array.from({ length: stopCount - 1 }).map((_, index) => (index + 1) * stepWidth);
|
|
if (props.range) {
|
|
return result.filter((step) => {
|
|
return step < 100 * (minValue.value - props.min) / (props.max - props.min) || step > 100 * (maxValue.value - props.min) / (props.max - props.min);
|
|
});
|
|
} else {
|
|
return result.filter((step) => step > 100 * (initData.firstValue - props.min) / (props.max - props.min));
|
|
}
|
|
});
|
|
const getStopStyle = (position) => {
|
|
return props.vertical ? { bottom: `${position}%` } : { left: `${position}%` };
|
|
};
|
|
return {
|
|
stops,
|
|
getStopStyle
|
|
};
|
|
};
|
|
|
|
exports.useStops = useStops;
|
|
//# sourceMappingURL=useStops.js.map
|