fix shake

This commit is contained in:
2026-07-02 13:49:44 +02:00
parent 262199e31a
commit be284db25c

45
app.js
View File

@@ -361,14 +361,7 @@
const stopTicks = () => (ticking = false); const stopTicks = () => (ticking = false);
// ZOOM sulla macchina + shake mentre gira // ZOOM sulla macchina + shake mentre gira
const slot = $(".slot"); zoomMachineIn();
slot.classList.add("zoom");
const shakeTimer = setTimeout(() => slot.classList.add("shake"), 460); // dopo lo zoom-in
const endZoom = () => {
clearTimeout(shakeTimer);
slot.classList.remove("shake"); // torna a scale(1.14) senza tremolio
requestAnimationFrame(() => slot.classList.remove("zoom")); // poi zoom-out fluido
};
const stopRiser = Audio.riser(wantTease ? 4.6 : 4.2); const stopRiser = Audio.riser(wantTease ? 4.6 : 4.2);
startTicks(); startTicks();
@@ -419,7 +412,38 @@
await sleep(260); await sleep(260);
} }
stopRiser(); stopRiser();
endZoom(); // fine scroll: la macchina torna allo stato normale // fine scroll: ferma il tremolio ma resta zoomata (il ritorno avviene
// dopo la vittoria, con una mini-animazione a molla — vedi zoomMachineOut)
zoomMachineSteady();
}
/* ---------- Zoom macchina ---------- */
let _shakeTimer = null;
function zoomMachineIn() {
const slot = $(".slot");
slot.getAnimations().forEach((a) => a.cancel()); // pulisce un eventuale ritorno in corso
slot.classList.add("zoom");
clearTimeout(_shakeTimer);
_shakeTimer = setTimeout(() => slot.classList.add("shake"), 460); // shake dopo lo zoom-in
}
function zoomMachineSteady() {
clearTimeout(_shakeTimer);
$(".slot").classList.remove("shake"); // resta zoomata, ma ferma
}
function zoomMachineOut() {
const slot = $(".slot");
clearTimeout(_shakeTimer);
slot.classList.remove("shake");
slot.classList.remove("zoom");
// mini-animazione a molla per tornare al posto (leggero rimbalzo sotto l'1)
slot.animate(
[
{ transform: "scale(1.14)" },
{ transform: "scale(0.985)" },
{ transform: "scale(1)" },
],
{ duration: 620, easing: "cubic-bezier(0.34, 1.56, 0.64, 1)" }
);
} }
/* ---------- Stato di gioco ---------- */ /* ---------- Stato di gioco ---------- */
@@ -666,6 +690,9 @@
} }
Audio.coin(); Audio.coin();
// la macchina resta zoomata per godersi la vittoria, poi torna al posto
setTimeout(zoomMachineOut, isJackpot ? 1200 : 800);
cursor++; cursor++;
setProgress(); setProgress();
renderLeaderboard(); renderLeaderboard();