mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +02:00
Fix problems when holding NumberStepper's buttons
This commit is contained in:
parent
2df3bb4611
commit
7dacc8f23a
@ -211,10 +211,13 @@ export class SettingElement {
|
|||||||
onChange && onChange(e, value);
|
onChange && onChange(e, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const onMouseDown = (e: MouseEvent | TouchEvent) => {
|
const onMouseDown = (e: PointerEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
isHolding = true;
|
isHolding = true;
|
||||||
|
|
||||||
const args = arguments;
|
const args = arguments;
|
||||||
|
interval && clearInterval(interval);
|
||||||
interval = window.setInterval(() => {
|
interval = window.setInterval(() => {
|
||||||
const event = new Event('click');
|
const event = new Event('click');
|
||||||
(event as any).arguments = args;
|
(event as any).arguments = args;
|
||||||
@ -223,11 +226,15 @@ export class SettingElement {
|
|||||||
}, 200);
|
}, 200);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMouseUp = (e: MouseEvent | TouchEvent) => {
|
const onMouseUp = (e: PointerEvent) => {
|
||||||
clearInterval(interval);
|
e.preventDefault();
|
||||||
|
|
||||||
|
interval && clearInterval(interval);
|
||||||
isHolding = false;
|
isHolding = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onContextMenu = (e: Event) => e.preventDefault();
|
||||||
|
|
||||||
// Custom method
|
// Custom method
|
||||||
($wrapper as any).setValue = (value: any) => {
|
($wrapper as any).setValue = (value: any) => {
|
||||||
$text.textContent = value + options.suffix;
|
$text.textContent = value + options.suffix;
|
||||||
@ -235,16 +242,14 @@ export class SettingElement {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$decBtn.addEventListener('click', onClick);
|
$decBtn.addEventListener('click', onClick);
|
||||||
$decBtn.addEventListener('mousedown', onMouseDown);
|
$decBtn.addEventListener('pointerdown', onMouseDown);
|
||||||
$decBtn.addEventListener('mouseup', onMouseUp);
|
$decBtn.addEventListener('pointerup', onMouseUp);
|
||||||
$decBtn.addEventListener('touchstart', onMouseDown);
|
$decBtn.addEventListener('contextmenu', onContextMenu);
|
||||||
$decBtn.addEventListener('touchend', onMouseUp);
|
|
||||||
|
|
||||||
$incBtn.addEventListener('click', onClick);
|
$incBtn.addEventListener('click', onClick);
|
||||||
$incBtn.addEventListener('mousedown', onMouseDown);
|
$incBtn.addEventListener('pointerdown', onMouseDown);
|
||||||
$incBtn.addEventListener('mouseup', onMouseUp);
|
$incBtn.addEventListener('pointerup', onMouseUp);
|
||||||
$incBtn.addEventListener('touchstart', onMouseDown);
|
$incBtn.addEventListener('contextmenu', onContextMenu);
|
||||||
$incBtn.addEventListener('touchend', onMouseUp);
|
|
||||||
|
|
||||||
return $wrapper;
|
return $wrapper;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user