mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-09-23 08:32:51 +00:00
fix(ClickParticles): clear remaining particles and remove click effects when animations are disabled (#178)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { useConfig } from "../../context/LauncherContext";
|
||||||
|
|
||||||
const SGA_CHARS = "abcdefghijklmnopqrstuvwxyz".split("");
|
const SGA_CHARS = "abcdefghijklmnopqrstuvwxyz".split("");
|
||||||
|
|
||||||
@@ -15,7 +16,11 @@ interface Particle {
|
|||||||
export const ClickParticles: React.FC = React.memo(() => {
|
export const ClickParticles: React.FC = React.memo(() => {
|
||||||
const [bursts, setBursts] = useState<Particle[]>([]);
|
const [bursts, setBursts] = useState<Particle[]>([]);
|
||||||
|
|
||||||
|
const { animationsEnabled } = useConfig();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!animationsEnabled) return;
|
||||||
|
|
||||||
const handlePressSound = (e: MouseEvent) => {
|
const handlePressSound = (e: MouseEvent) => {
|
||||||
const newParticles: Particle[] = [];
|
const newParticles: Particle[] = [];
|
||||||
const particleCount = 8;
|
const particleCount = 8;
|
||||||
@@ -40,7 +45,13 @@ export const ClickParticles: React.FC = React.memo(() => {
|
|||||||
|
|
||||||
window.addEventListener("mousedown", handlePressSound);
|
window.addEventListener("mousedown", handlePressSound);
|
||||||
return () => window.removeEventListener("mousedown", handlePressSound);
|
return () => window.removeEventListener("mousedown", handlePressSound);
|
||||||
}, []);
|
}, [animationsEnabled]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!animationsEnabled) {
|
||||||
|
setBursts([]);
|
||||||
|
}
|
||||||
|
}, [animationsEnabled])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 pointer-events-none z-[9999] overflow-hidden">
|
<div className="fixed inset-0 pointer-events-none z-[9999] overflow-hidden">
|
||||||
|
|||||||
Reference in New Issue
Block a user