Skip to content

Commit ca5e593

Browse files
committed
Fix: Replace JS inline clip-path logic with hardware-accelerated CSS keyframe defrost animation
1 parent cb71bb0 commit ca5e593

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

index.html

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,20 @@
297297
opacity: 1;
298298
z-index: 3;
299299
clip-path: inset(100% 0 0 0); /* Clipped out completely by default */
300-
transition: clip-path 120ms linear; /* Smooth linear rising transition */
300+
}
301+
302+
/* Defrosting Clip-Path Rise Animation */
303+
@keyframes defrost-rise {
304+
0% {
305+
clip-path: inset(100% 0 0 0);
306+
}
307+
100% {
308+
clip-path: inset(0% 0 0 0);
309+
}
310+
}
311+
312+
.tile.loading .sprite-static-color {
313+
animation: defrost-rise 450ms cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
301314
}
302315

303316
.sprite-player {
@@ -1033,19 +1046,15 @@ <h2>Available Animated Pixel Companions for Codex:</h2>
10331046
tile._anim = requestAnimationFrame(tick);
10341047
}
10351048

1036-
// Always set the loading class to trigger the elegant rising steam particles!
1049+
// Always set the loading class to trigger the elegant rising steam particles and CSS defrost-rise animation!
10371050
tile.classList.add("loading");
10381051

10391052
const colorEl = tile._spriteStaticColor;
10401053
if (colorEl) {
1041-
// Force layout reflow to ensure the 100% starting point is registered
1042-
colorEl.style.transition = "none";
1043-
colorEl.style.clipPath = "inset(100% 0 0 0)";
1044-
colorEl.getBoundingClientRect(); // trigger reflow
1045-
1046-
// Apply a smooth 450ms CSS clip-path transition for the color defrosting
1047-
colorEl.style.transition = "clip-path 450ms cubic-bezier(0.25, 0.8, 0.25, 1)";
1048-
colorEl.style.clipPath = "inset(0% 0 0 0)";
1054+
// Clear any inline styles to let the pristine stylesheet CSS animation run flawlessly
1055+
colorEl.style.animation = "";
1056+
colorEl.style.transition = "";
1057+
colorEl.style.clipPath = "";
10491058
}
10501059

10511060
const hoverStartTime = Date.now();
@@ -1062,6 +1071,7 @@ <h2>Available Animated Pixel Companions for Codex:</h2>
10621071
if (timeElapsed > minDefrostDuration) {
10631072
if (!tile._isHovered) return;
10641073
if (colorEl) {
1074+
colorEl.style.animation = "none"; // Disable CSS animation to take manual control
10651075
colorEl.style.transition = "none";
10661076
const insetTop = 100 - pct;
10671077
colorEl.style.clipPath = `inset(${insetTop}% 0 0 0)`;
@@ -1084,8 +1094,9 @@ <h2>Available Animated Pixel Companions for Codex:</h2>
10841094
if (!tile._isHovered) {
10851095
tile.classList.remove("playing");
10861096
if (colorEl) {
1087-
colorEl.style.transition = "none";
1088-
colorEl.style.clipPath = "inset(100% 0 0 0)";
1097+
colorEl.style.animation = "";
1098+
colorEl.style.transition = "";
1099+
colorEl.style.clipPath = "";
10891100
}
10901101
return;
10911102
}
@@ -1110,9 +1121,10 @@ <h2>Available Animated Pixel Companions for Codex:</h2>
11101121
}
11111122
const colorEl = tile._spriteStaticColor;
11121123
if (colorEl) {
1113-
// Snap back to grayscale instantly on leave
1114-
colorEl.style.transition = "none";
1115-
colorEl.style.clipPath = "inset(100% 0 0 0)";
1124+
// Snap back to grayscale instantly on leave by clearing inline styles to default CSS
1125+
colorEl.style.animation = "";
1126+
colorEl.style.transition = "";
1127+
colorEl.style.clipPath = "";
11161128
}
11171129
}
11181130

0 commit comments

Comments
 (0)