-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDot.jsx
More file actions
45 lines (38 loc) · 1.08 KB
/
Dot.jsx
File metadata and controls
45 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React, { useEffect, useState } from 'react';
const Dot = ({
id,
size,
color,
initialX,
initialY,
animationDuration,
onAnimationEnd,
}) => {
const [isVisible, setIsVisible] = useState(true);
useEffect(() => {
const timer = setTimeout(() => {
setIsVisible(false);
onAnimationEnd(id);
}, animationDuration * 1000); // Convert seconds to milliseconds
return () => clearTimeout(timer);
}, [animationDuration, id, onAnimationEnd]);
if (!isVisible) {
return null;
}
const dotStyle = {
position: 'absolute',
left: `${initialX}px`,
top: `${initialY}px`,
width: `${size}px`,
height: `${size}px`,
backgroundColor: color,
opacity: 0.7,
animation: `moveAndFade ${animationDuration}s linear forwards`,
zIndex: 0, // Ensure dots are behind content
};
// Define keyframes dynamically or ensure they are globally available
// For now, we'll assume keyframes are defined in index.css or similar
// This is a placeholder for the actual CSS animation
return <div style={dotStyle} />;
};
export default Dot;