Fix meteor animation: animate transform instead of static translate
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1e9b63e577
commit
238c56eba4
1 changed files with 4 additions and 4 deletions
|
|
@ -122,10 +122,10 @@ html, body {
|
|||
animation: meteorFall linear forwards;
|
||||
}
|
||||
@keyframes meteorFall {
|
||||
0% { opacity: 0; }
|
||||
0% { opacity: 0; transform: rotate(var(--rot)) translateY(0); }
|
||||
5% { opacity: 1; }
|
||||
85% { opacity: 1; }
|
||||
100% { opacity: 0; }
|
||||
100% { opacity: 0; transform: rotate(var(--rot)) translateY(var(--dist)); }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
|
|
@ -911,13 +911,13 @@ function spawnMeteor() {
|
|||
const dur = 1.2 + Math.random() * 1.8; // seconds
|
||||
const color = `rgba(${180+Math.random()*75|0},${180+Math.random()*75|0},255,0.9)`;
|
||||
el.style.cssText = `
|
||||
--rot:${angle}deg;
|
||||
--dist:${(window.innerHeight + len * 2)}px;
|
||||
left:${x}%; top:${-len}px;
|
||||
height:${len}px;
|
||||
background:linear-gradient(to bottom, transparent, ${color});
|
||||
transform:rotate(${angle}deg);
|
||||
animation-duration:${dur}s;
|
||||
animation-name:meteorFall;
|
||||
translate:0 ${(window.innerHeight + len) * 1.3}px;
|
||||
`;
|
||||
document.querySelector('.scene').appendChild(el);
|
||||
setTimeout(() => el.remove(), dur * 1000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue