From 4fcf05844b2259c8be6c50f3cdf1e373d3903366 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 26 May 2025 04:14:34 +0200 Subject: [PATCH] Refactor and optimize animeCat.js for better performance and readability --- animeCat.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/animeCat.js b/animeCat.js index e3290db..e667519 100644 --- a/animeCat.js +++ b/animeCat.js @@ -282,35 +282,26 @@ _bindMouseHold() { // Bild auf joy.png setzen: img.src = this.images.joy || this.images.default; - // Wrapper animieren: nach oben + rechts, leicht rotieren + // Nach oben springen und nach RECHTS rotieren: wrapper.style.transition = 'transform 0.6s cubic-bezier(.19,1,.22,1)'; - wrapper.style.transform = 'translateY(-40px) rotate(12deg)'; + wrapper.style.transform = 'translateY(-40px) rotate(12deg)'; // <--- POSITIV! - // Herzchen-Explosion starten this._spawnHearts(12); - // Nach 0.4s (Sprung oben), dann warten (stehen lassen) setTimeout(() => { - // Nach weiteren 2.2s zurückfallen (gesamt ca. 2.6s joy-mode) setTimeout(() => { - // Rücksprung: nach unten + // Rücksprung nach unten, zurückdrehen: wrapper.style.transition = 'transform 0.8s cubic-bezier(.19,1,.22,1)'; wrapper.style.transform = 'translateY(0) rotate(0deg)'; - - // → → → Hier: Bild auf mouth_open setzen! img.src = this.images.mouthOpen || this.images.default; - - // Nach 3 Sekunden: Bild zurück zu default setTimeout(() => { img.src = this.images.default; - // Reset nach 0.7s (Animation zu Ende) setTimeout(() => { wrapper.style.transition = origTransition || ''; wrapper.style.transform = origTransform || ''; if (typeof onFinish === 'function') onFinish(); }, 700); }, 2000); - }, 2200); }, 400); }