auto-git:
[change] animeCat.js
This commit is contained in:
80
animeCat.js
80
animeCat.js
@@ -390,47 +390,57 @@ _runJoyAnimation(onFinish) {
|
|||||||
setTimeout(() => this._makeHeart(), Math.random() * 300);
|
setTimeout(() => this._makeHeart(), Math.random() * 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_makeHeart() {
|
||||||
|
// Emoji oder eigenes Bild
|
||||||
|
const emoji = Math.random() < 0.7 ? '❤️' : '💕';
|
||||||
|
|
||||||
_makeHeart() {
|
const heart = document.createElement('span');
|
||||||
// Emoji oder eigenes Bild
|
heart.textContent = emoji;
|
||||||
const emoji = Math.random() < 0.7 ? '❤️' : '💕';
|
heart.style.position = 'absolute';
|
||||||
|
|
||||||
const heart = document.createElement('span');
|
// Startposition relativ zur Katze berechnen:
|
||||||
heart.textContent = emoji;
|
const catRect = this.img.getBoundingClientRect();
|
||||||
heart.style.position = 'absolute';
|
const containerRect = this.container.getBoundingClientRect();
|
||||||
heart.style.left = '30%';
|
|
||||||
heart.style.bottom= '45%';
|
|
||||||
heart.style.fontSize = `${16 + Math.random() * 14}px`;
|
|
||||||
heart.style.pointerEvents = 'none';
|
|
||||||
heart.style.opacity = '0.9';
|
|
||||||
heart.style.zIndex = 10;
|
|
||||||
|
|
||||||
// Start/End-Pos, Flugwinkel
|
// Starte etwas über dem Mittelpunkt der Katze
|
||||||
const angle = (Math.random() * Math.PI) - (Math.PI/2); // spread -90° to 90°
|
const left = (catRect.left + catRect.width * 0.5) - containerRect.left;
|
||||||
const distance = 60 + Math.random() * 45;
|
const bottom = (containerRect.bottom - (catRect.top + catRect.height * 0.4));
|
||||||
const dx = Math.cos(angle) * distance;
|
heart.style.left = `${left}px`;
|
||||||
const dy = Math.sin(angle) * distance;
|
heart.style.bottom = `${bottom}px`;
|
||||||
|
|
||||||
heart.animate([
|
heart.style.fontSize = `${16 + Math.random() * 14}px`;
|
||||||
{
|
heart.style.pointerEvents = 'none';
|
||||||
transform: 'translate(-50%, 0) scale(1)',
|
heart.style.opacity = '0.9';
|
||||||
opacity: 0.95
|
heart.style.zIndex = 1000;
|
||||||
},
|
|
||||||
{
|
|
||||||
transform: `translate(calc(-50% + ${dx}px), ${-dy}px) scale(${1.3 + Math.random()*0.4}) rotate(${Math.random()*60-30}deg)`,
|
|
||||||
opacity: 0.3
|
|
||||||
}
|
|
||||||
], {
|
|
||||||
duration: 1100 + Math.random()*800,
|
|
||||||
easing: 'cubic-bezier(.28,1.01,.57,.99)'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Remove after animation
|
// Start/End-Pos, Flugwinkel
|
||||||
setTimeout(() => heart.remove(), 1600);
|
const angle = (Math.random() * Math.PI) - (Math.PI/2); // spread -90° to 90°
|
||||||
|
const distance = 60 + Math.random() * 45;
|
||||||
|
const dx = Math.cos(angle) * distance;
|
||||||
|
const dy = Math.sin(angle) * distance;
|
||||||
|
|
||||||
// Im Cat-Wrapper anbringen:
|
heart.animate([
|
||||||
this.wrapper.appendChild(heart);
|
{
|
||||||
}
|
transform: 'translate(-50%, 0) scale(1)',
|
||||||
|
opacity: 0.95
|
||||||
|
},
|
||||||
|
{
|
||||||
|
transform: `translate(calc(-50% + ${dx}px), ${-dy}px) scale(${1.3 + Math.random()*0.4}) rotate(${Math.random()*60-30}deg)`,
|
||||||
|
opacity: 0.3
|
||||||
|
}
|
||||||
|
], {
|
||||||
|
duration: 1100 + Math.random()*800,
|
||||||
|
easing: 'cubic-bezier(.28,1.01,.57,.99)'
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => heart.remove(), 1600);
|
||||||
|
|
||||||
|
// Jetzt direkt in den Container anhängen (NICHT an this.wrapper!)
|
||||||
|
this.container.appendChild(heart);
|
||||||
|
|
||||||
|
return heart;
|
||||||
|
}
|
||||||
|
|
||||||
/** Call when streaming text begins */
|
/** Call when streaming text begins */
|
||||||
beginSpeech() {
|
beginSpeech() {
|
||||||
|
|||||||
Reference in New Issue
Block a user