diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2022-06-30 12:42:35 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2022-06-30 12:42:35 +0900 |
| commit | fa6eb0e0f2dd44c5adcaaf34c02700c805bd8530 (patch) | |
| tree | edd5aa348d366b01405201c8831316099315003f | |
| parent | tweak client (diff) | |
| download | sharkey-fa6eb0e0f2dd44c5adcaaf34c02700c805bd8530.tar.gz sharkey-fa6eb0e0f2dd44c5adcaaf34c02700c805bd8530.tar.bz2 sharkey-fa6eb0e0f2dd44c5adcaaf34c02700c805bd8530.zip | |
perf(client): improve range control performance
| -rw-r--r-- | packages/client/src/components/form/range.vue | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/client/src/components/form/range.vue b/packages/client/src/components/form/range.vue index 9bb0164a2e..7ef727d571 100644 --- a/packages/client/src/components/form/range.vue +++ b/packages/client/src/components/form/range.vue @@ -78,9 +78,6 @@ export default defineComponent({ return (steppedRawValue.value * (props.max - props.min)) + props.min; } }); - watch(finalValue, () => { - context.emit('update:modelValue', finalValue.value); - }); const thumbWidth = computed(() => { 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))); }; + let beforeValue = finalValue.value; + const onMouseup = () => { document.head.removeChild(style); tooltipShowing.value = false; @@ -148,6 +147,11 @@ export default defineComponent({ window.removeEventListener('touchmove', onDrag); window.removeEventListener('mouseup', onMouseup); window.removeEventListener('touchend', onMouseup); + + // 値が変わってたら通知 + if (beforeValue !== finalValue.value) { + context.emit('update:modelValue', finalValue.value); + } }; window.addEventListener('mousemove', onDrag); |