mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-12 15:04:33 +00:00
perf(frontend): tweak MkRange
This commit is contained in:
parent
6e929ece6f
commit
e0d8702839
1 changed files with 2 additions and 1 deletions
|
@ -159,12 +159,13 @@ function onMousedown(ev: MouseEvent | TouchEvent) {
|
||||||
|
|
||||||
const onDrag = (ev: MouseEvent | TouchEvent) => {
|
const onDrag = (ev: MouseEvent | TouchEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
let beforeValue = finalValue.value;
|
||||||
const containerRect = containerEl.value!.getBoundingClientRect();
|
const containerRect = containerEl.value!.getBoundingClientRect();
|
||||||
const pointerX = 'touches' in ev && ev.touches.length > 0 ? ev.touches[0].clientX : 'clientX' in ev ? ev.clientX : 0;
|
const pointerX = 'touches' in ev && ev.touches.length > 0 ? ev.touches[0].clientX : 'clientX' in ev ? ev.clientX : 0;
|
||||||
const pointerPositionOnContainer = pointerX - (containerRect.left + (thumbWidth / 2));
|
const pointerPositionOnContainer = pointerX - (containerRect.left + (thumbWidth / 2));
|
||||||
rawValue.value = Math.min(1, Math.max(0, pointerPositionOnContainer / (containerEl.value!.offsetWidth - thumbWidth)));
|
rawValue.value = Math.min(1, Math.max(0, pointerPositionOnContainer / (containerEl.value!.offsetWidth - thumbWidth)));
|
||||||
|
|
||||||
if (props.continuousUpdate) {
|
if (props.continuousUpdate && beforeValue !== finalValue.value) {
|
||||||
emit('update:modelValue', finalValue.value);
|
emit('update:modelValue', finalValue.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue