mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 14:23:09 +02:00
perf(client): improve range control performance
This commit is contained in:
parent
bffe6fb9bf
commit
fa6eb0e0f2
1 changed files with 7 additions and 3 deletions
|
@ -78,9 +78,6 @@ export default defineComponent({
|
||||||
return (steppedRawValue.value * (props.max - props.min)) + props.min;
|
return (steppedRawValue.value * (props.max - props.min)) + props.min;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
watch(finalValue, () => {
|
|
||||||
context.emit('update:modelValue', finalValue.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const thumbWidth = computed(() => {
|
const thumbWidth = computed(() => {
|
||||||
if (thumbEl.value == null) return 0;
|
if (thumbEl.value == null) return 0;
|
||||||
|
@ -141,6 +138,8 @@ export default defineComponent({
|
||||||
rawValue.value = Math.min(1, Math.max(0, pointerPositionOnContainer / (containerEl.value!.offsetWidth - thumbWidth.value)));
|
rawValue.value = Math.min(1, Math.max(0, pointerPositionOnContainer / (containerEl.value!.offsetWidth - thumbWidth.value)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let beforeValue = finalValue.value;
|
||||||
|
|
||||||
const onMouseup = () => {
|
const onMouseup = () => {
|
||||||
document.head.removeChild(style);
|
document.head.removeChild(style);
|
||||||
tooltipShowing.value = false;
|
tooltipShowing.value = false;
|
||||||
|
@ -148,6 +147,11 @@ export default defineComponent({
|
||||||
window.removeEventListener('touchmove', onDrag);
|
window.removeEventListener('touchmove', onDrag);
|
||||||
window.removeEventListener('mouseup', onMouseup);
|
window.removeEventListener('mouseup', onMouseup);
|
||||||
window.removeEventListener('touchend', onMouseup);
|
window.removeEventListener('touchend', onMouseup);
|
||||||
|
|
||||||
|
// 値が変わってたら通知
|
||||||
|
if (beforeValue !== finalValue.value) {
|
||||||
|
context.emit('update:modelValue', finalValue.value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('mousemove', onDrag);
|
window.addEventListener('mousemove', onDrag);
|
||||||
|
|
Loading…
Reference in a new issue