Add mobile vibration when card shakes

This commit is contained in:
chris 2025-11-20 10:58:39 -05:00
parent 8efe87fadf
commit ea39f02459

10
app.js
View File

@ -533,6 +533,11 @@
} }
} }
function triggerShake(card) {
triggerShake(card);
if (navigator.vibrate) navigator.vibrate([90, 40, 90]);
}
function openStats() { function openStats() {
game.active = false; game.active = false;
clearInterval(dementor.interval); clearInterval(dementor.interval);
@ -865,10 +870,7 @@
// guard in case question changed // guard in case question changed
const currentId = `${Math.min(game.currentFact.n1, game.currentFact.n2)}x${Math.max(game.currentFact.n1, game.currentFact.n2)}`; const currentId = `${Math.min(game.currentFact.n1, game.currentFact.n2)}x${Math.max(game.currentFact.n1, game.currentFact.n2)}`;
if (currentId !== factId) return; if (currentId !== factId) return;
if (card) { triggerShake(card);
card.classList.add('apply-shake');
setTimeout(() => card.classList.remove('apply-shake'), 500);
}
feedback.style.color = '#ffb0b0'; feedback.style.color = '#ffb0b0';
feedback.innerText = `Answer is ${game.currentFact.ans}.${penalty ? ` (-${penalty} XP)` : ''} Press CAST to continue.`; feedback.innerText = `Answer is ${game.currentFact.ans}.${penalty ? ` (-${penalty} XP)` : ''} Press CAST to continue.`;
addToTroubleList(game.currentFact.n1, game.currentFact.n2); addToTroubleList(game.currentFact.n1, game.currentFact.n2);