90d3989322721b1bdec4120d91e6e9391afdd95149583372bdf3d30e2ae0954c578e837c5eb279732f072e0b5ed6eeee6e22333ea4f1a267e5057bc910966d 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. const useStops = (props, initData, minValue, maxValue) => {
  5. const stops = vue.computed(() => {
  6. if (!props.showStops || props.min > props.max)
  7. return [];
  8. if (props.step === 0) {
  9. return [];
  10. }
  11. const stopCount = (props.max - props.min) / props.step;
  12. const stepWidth = 100 * props.step / (props.max - props.min);
  13. const result = Array.from({ length: stopCount - 1 }).map((_, index) => (index + 1) * stepWidth);
  14. if (props.range) {
  15. return result.filter((step) => {
  16. return step < 100 * (minValue.value - props.min) / (props.max - props.min) || step > 100 * (maxValue.value - props.min) / (props.max - props.min);
  17. });
  18. } else {
  19. return result.filter((step) => step > 100 * (initData.firstValue - props.min) / (props.max - props.min));
  20. }
  21. });
  22. const getStopStyle = (position) => {
  23. return props.vertical ? { bottom: `${position}%` } : { left: `${position}%` };
  24. };
  25. return {
  26. stops,
  27. getStopStyle
  28. };
  29. };
  30. exports.useStops = useStops;
  31. //# sourceMappingURL=use-stops.js.map