Call vibration only on user-driven shakes
This commit is contained in:
parent
804c34ef61
commit
f8f83f2f37
11
app.js
11
app.js
@ -533,12 +533,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerShake(card) {
|
function triggerShake(card, vibrate = true) {
|
||||||
if (card) {
|
if (card) {
|
||||||
card.classList.add('apply-shake');
|
card.classList.add('apply-shake');
|
||||||
setTimeout(() => card.classList.remove('apply-shake'), 500);
|
setTimeout(() => card.classList.remove('apply-shake'), 500);
|
||||||
}
|
}
|
||||||
if (navigator.vibrate) navigator.vibrate([90, 40, 90]);
|
if (vibrate && navigator.vibrate) navigator.vibrate([90, 40, 90]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openStats() {
|
function openStats() {
|
||||||
@ -839,10 +839,7 @@
|
|||||||
state.streak = 0;
|
state.streak = 0;
|
||||||
game.attempts = timedOut ? 3 : game.attempts + 1;
|
game.attempts = timedOut ? 3 : game.attempts + 1;
|
||||||
const penalty = game.attempts >= 3 || timedOut ? 10 : (game.attempts === 2 ? 5 : 0);
|
const penalty = game.attempts >= 3 || timedOut ? 10 : (game.attempts === 2 ? 5 : 0);
|
||||||
if (card) {
|
triggerShake(card, !timedOut);
|
||||||
card.classList.add('apply-shake');
|
|
||||||
setTimeout(() => card.classList.remove('apply-shake'), 500);
|
|
||||||
}
|
|
||||||
if (!timedOut) {
|
if (!timedOut) {
|
||||||
dementor.progress += 0.2; updateDementorVisuals();
|
dementor.progress += 0.2; updateDementorVisuals();
|
||||||
game.currentInput = "";
|
game.currentInput = "";
|
||||||
@ -873,7 +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;
|
||||||
triggerShake(card);
|
triggerShake(card, false); // triggered from timeout; not a direct gesture
|
||||||
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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user