fix(ClickParticles): clear remaining particles and remove click effects when animations are disabled (#178)

This commit is contained in:
João Pedro Carvalho
2026-08-11 13:31:19 +03:00
committed by GitHub
parent 51a95949ad
commit 816997803a
+12 -1
View File
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from "react";
import { useConfig } from "../../context/LauncherContext";
const SGA_CHARS = "abcdefghijklmnopqrstuvwxyz".split("");
@@ -15,7 +16,11 @@ interface Particle {
export const ClickParticles: React.FC = React.memo(() => {
const [bursts, setBursts] = useState<Particle[]>([]);
const { animationsEnabled } = useConfig();
useEffect(() => {
if (!animationsEnabled) return;
const handlePressSound = (e: MouseEvent) => {
const newParticles: Particle[] = [];
const particleCount = 8;
@@ -40,7 +45,13 @@ export const ClickParticles: React.FC = React.memo(() => {
window.addEventListener("mousedown", handlePressSound);
return () => window.removeEventListener("mousedown", handlePressSound);
}, []);
}, [animationsEnabled]);
useEffect(() => {
if (!animationsEnabled) {
setBursts([]);
}
}, [animationsEnabled])
return (
<div className="fixed inset-0 pointer-events-none z-[9999] overflow-hidden">