mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 09:12:40 +02:00
Merge pull request #958 from LikiosSedo/fix/hero-section-timeout-cleanup
fix: add missing `setTimeout` cleanup in hero section collision effect
This commit is contained in:
commit
c69085def7
1 changed files with 17 additions and 14 deletions
|
|
@ -277,21 +277,24 @@ const CollisionMechanism = ({
|
||||||
}, [cycleCollisionDetected, parentRef]);
|
}, [cycleCollisionDetected, parentRef]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (collision.detected && collision.coordinates) {
|
if (!collision.detected || !collision.coordinates) return;
|
||||||
setTimeout(() => {
|
|
||||||
setCollision({ detected: false, coordinates: null });
|
|
||||||
setCycleCollisionDetected(false);
|
|
||||||
// Set beam opacity to 0
|
|
||||||
if (beamRef.current) {
|
|
||||||
beamRef.current.style.opacity = "1";
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
// Reset the beam animation after a delay
|
const timer1 = setTimeout(() => {
|
||||||
setTimeout(() => {
|
setCollision({ detected: false, coordinates: null });
|
||||||
setBeamKey((prevKey) => prevKey + 1);
|
setCycleCollisionDetected(false);
|
||||||
}, 2000);
|
if (beamRef.current) {
|
||||||
}
|
beamRef.current.style.opacity = "1";
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
const timer2 = setTimeout(() => {
|
||||||
|
setBeamKey((prevKey) => prevKey + 1);
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timer1);
|
||||||
|
clearTimeout(timer2);
|
||||||
|
};
|
||||||
}, [collision]);
|
}, [collision]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue