Skip to content

Commit ffde7a1

Browse files
Bikram GoleBikram Gole
authored andcommitted
Respect reduced-motion for pulse effects
1 parent 2c281e5 commit ffde7a1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

script.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ if (prefersReducedMotion) {
174174
const heroZone = document.getElementById("hero-zone") || document.querySelector(".hero");
175175
function triggerHeroPulse() {
176176
if (!heroZone) return;
177+
if (prefersReducedMotion) return;
177178
heroZone.classList.remove("pulse-hit");
178179
void heroZone.offsetWidth;
179180
heroZone.classList.add("pulse-hit");
@@ -846,6 +847,7 @@ function playPulseSound(pulseCount = 1) {
846847

847848
function triggerPenguinPowerUp() {
848849
if (!penguinAvatar) return;
850+
if (prefersReducedMotion) return;
849851

850852
penguinAvatar.classList.remove("power-up");
851853
// Restart animation if pulses happen quickly.
@@ -2202,7 +2204,8 @@ function showToast(message) {
22022204
}
22032205

22042206
function spawnSparks(total) {
2205-
const { isConstrained, isFirefoxLike } = runtimeFlags;
2207+
const { isConstrained, isFirefoxLike, saveData } = runtimeFlags;
2208+
if (prefersReducedMotion || saveData) return;
22062209
const densityScale = isConstrained ? 0.35 : (isFirefoxLike ? 0.55 : 1);
22072210
const batchTotal = Math.max(3, Math.round(total * densityScale));
22082211
const fragment = document.createDocumentFragment();

0 commit comments

Comments
 (0)