Mobile haptic feedback

This commit is contained in:
space-nuko
2023-05-07 16:56:16 -05:00
parent 6dd2627f2c
commit 8ec2301093
9 changed files with 112 additions and 25 deletions

View File

@@ -57,7 +57,6 @@
function onRelease(e: Event) {
if (nodeValue && option) {
$nodeValue = option
navigator.vibrate(100)
}
}
@@ -78,11 +77,26 @@
}
function onPointerDown(e: PointerEvent) {
if (!isMobile)
return;
interfaceState.showIndicator(e.clientX, e.clientY, option);
}
let canVibrate = true;
let lastDisplayValue = null;
function onPointerMove(e: PointerEvent) {
if (!isMobile)
return;
interfaceState.showIndicator(e.clientX, e.clientY, option);
if (canVibrate && lastDisplayValue != option) {
lastDisplayValue = option;
canVibrate = false;
setTimeout(() => { canVibrate = true }, 30)
navigator.vibrate(10)
}
}
</script>