fix(ClickParticles): clear remaining particles and remove click effects when animations are disabled (#178)
Some checks failed
Nix / build (push) Has been cancelled

This commit is contained in:
João Pedro Carvalho 2026-08-11 07:31:19 -03:00 committed by GitHub
parent 51a95949ad
commit 816997803a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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,8 +45,14 @@ 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">
{bursts.map((p) => (