Enhance vibration pattern on game win with error handling

This commit is contained in:
2026-02-21 23:24:40 +00:00
parent d488531358
commit 6fc3e1c057

View File

@@ -36,10 +36,14 @@ const handleKeyDown = (e) => {
const triggerVibration = () => {
if (!('vibrate' in navigator)) return;
try {
const isCoarse = window.matchMedia?.('(pointer: coarse)')?.matches;
const isTouch = navigator.maxTouchPoints && navigator.maxTouchPoints > 0;
if (isCoarse || isTouch) {
navigator.vibrate([80, 40, 120, 40, 180]);
navigator.vibrate([200, 100, 200, 100, 200]);
}
} catch (e) {
console.error('Vibration failed:', e);
}
};