Skip to content

Commit f882b3e

Browse files
committed
Atoms - Slicer - Add refresh endpoints props
1 parent 3e61373 commit f882b3e

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

src/atoms/Slicer.vue

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ const props = defineProps({
8989
minimapIndicatorColor: {
9090
type: String,
9191
default: '#2D353C'
92+
},
93+
refreshStartPoint: {
94+
type: Number,
95+
default: 0
96+
},
97+
refreshEndPoint: {
98+
type: Number,
99+
default: null
92100
}
93101
});
94102
@@ -97,6 +105,10 @@ const endValue = ref(props.max);
97105
const hasMinimap = computed(() => !!props.minimap.length);
98106
const uid = ref(createUid());
99107
108+
const endpoint = computed(() => {
109+
return props.refreshEndPoint === null ? props.max : props.refreshEndPoint;
110+
})
111+
100112
const emit = defineEmits(['update:start', 'update:end', 'reset', 'trapMouse']);
101113
102114
const highlightStyle = computed(() => {
@@ -264,12 +276,37 @@ function trapMouse(trap) {
264276
}
265277
}
266278
279+
const inputStep = ref(0)
280+
const rangeStart = ref(null);
281+
const rangeEnd = ref(null);
282+
283+
function setStartValue(value) {
284+
startValue.value = value;
285+
if (rangeStart.value) {
286+
rangeStart.value.value = value;
287+
}
288+
emit('update:start', Number(startValue.value));
289+
}
290+
291+
function setEndValue(value) {
292+
endValue.value = value;
293+
if (rangeEnd.value) {
294+
rangeEnd.value.value = value;
295+
}
296+
emit('update:end', Number(endValue.value));
297+
}
298+
299+
defineExpose({
300+
setStartValue,
301+
setEndValue
302+
})
303+
267304
</script>
268305

269306
<template>
270307
<div data-html2canvas-ignore data-cy="slicer" style="padding: 0 24px" class="vue-data-ui-zoom">
271308
<div class="vue-data-ui-slicer-labels" style="position: relative; z-index: 1; pointer-events: none;">
272-
<div v-if="valueStart > 0 || valueEnd < max" style="width: 100%; position: relative">
309+
<div v-if="valueStart !== refreshStartPoint || valueEnd !== endpoint" style="width: 100%; position: relative">
273310
<button
274311
v-if="!useResetSlot"
275312
data-cy-reset tabindex="0"
@@ -414,11 +451,11 @@ function trapMouse(trap) {
414451
</template>
415452
<div class="slider-track"></div>
416453
<div class="range-highlight" :style="highlightStyle"></div>
417-
<input type="range" class="range-left" :min="min" :max="max" v-model="startValue" @input="onStartInput" />
454+
<input ref="rangeStart" :key="`range-min${inputStep}`" type="range" class="range-left" :min="min" :max="max" v-model="startValue" @input="onStartInput" />
418455
<div class="thumb-label thumb-label-left" :style="leftLabelPosition">
419456
{{ labelLeft }}
420457
</div>
421-
<input type="range" class="range-right" :min="min" :max="max" v-model="endValue" @input="onEndInput" />
458+
<input ref="rangeEnd" type="range" class="range-right" :min="min" :max="max" v-model="endValue" @input="onEndInput" />
422459
<div class="thumb-label thumb-label-right" :style="rightLabelPosition">
423460
{{ labelRight }}
424461
</div>

0 commit comments

Comments
 (0)