Enhance vibration pattern on game win with error handling
This commit is contained in:
@@ -36,10 +36,14 @@ const handleKeyDown = (e) => {
|
|||||||
|
|
||||||
const triggerVibration = () => {
|
const triggerVibration = () => {
|
||||||
if (!('vibrate' in navigator)) return;
|
if (!('vibrate' in navigator)) return;
|
||||||
const isCoarse = window.matchMedia?.('(pointer: coarse)')?.matches;
|
try {
|
||||||
const isTouch = navigator.maxTouchPoints && navigator.maxTouchPoints > 0;
|
const isCoarse = window.matchMedia?.('(pointer: coarse)')?.matches;
|
||||||
if (isCoarse || isTouch) {
|
const isTouch = navigator.maxTouchPoints && navigator.maxTouchPoints > 0;
|
||||||
navigator.vibrate([80, 40, 120, 40, 180]);
|
if (isCoarse || isTouch) {
|
||||||
|
navigator.vibrate([200, 100, 200, 100, 200]);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Vibration failed:', e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user