fix shake
This commit is contained in:
45
app.js
45
app.js
@@ -361,14 +361,7 @@
|
||||
const stopTicks = () => (ticking = false);
|
||||
|
||||
// ZOOM sulla macchina + shake mentre gira
|
||||
const slot = $(".slot");
|
||||
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
|
||||
};
|
||||
zoomMachineIn();
|
||||
|
||||
const stopRiser = Audio.riser(wantTease ? 4.6 : 4.2);
|
||||
startTicks();
|
||||
@@ -419,7 +412,38 @@
|
||||
await sleep(260);
|
||||
}
|
||||
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 ---------- */
|
||||
@@ -666,6 +690,9 @@
|
||||
}
|
||||
Audio.coin();
|
||||
|
||||
// la macchina resta zoomata per godersi la vittoria, poi torna al posto
|
||||
setTimeout(zoomMachineOut, isJackpot ? 1200 : 800);
|
||||
|
||||
cursor++;
|
||||
setProgress();
|
||||
renderLeaderboard();
|
||||
|
||||
Reference in New Issue
Block a user