rocket-cursor-component 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/rocket.Cursor.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,6 +87,9 @@ Here's a demo of the Rocket Cursor in action:
|
|
|
87
87
|
- **Changed**: Rocket aligns by its nose to the cursor position (manual offsets removed)
|
|
88
88
|
- **Changed**: Demo cleaned up to match the new API (no offset sliders)
|
|
89
89
|
|
|
90
|
+
### 2.1.1
|
|
91
|
+
- **Fixed**: Flame visibility now updates reliably
|
|
92
|
+
|
|
90
93
|
### 2.0.0 (React 19+ Only)
|
|
91
94
|
- **BREAKING**: Now requires React 19.0.0 or higher
|
|
92
95
|
- **NEW**: Added `useId()` for unique SVG gradient IDs (prevents collisions)
|
package/dist/rocket.Cursor.js
CHANGED
|
@@ -32,6 +32,7 @@ const RocketCursor = ({ size = 50, threshold = 10, flameHideTimeout = 300, isVis
|
|
|
32
32
|
const lastMoveTs = useRef(Date.now());
|
|
33
33
|
const rafRef = useRef(null);
|
|
34
34
|
const [isMoving, setIsMoving] = useState(false);
|
|
35
|
+
const isMovingRef = useRef(false);
|
|
35
36
|
const [visible, setVisible] = useState(isVisible);
|
|
36
37
|
const lastSignificantPosition = useRef(Object.assign({}, target.current));
|
|
37
38
|
const flameTimeoutRef = useRef(null);
|
|
@@ -70,16 +71,21 @@ const RocketCursor = ({ size = 50, threshold = 10, flameHideTimeout = 300, isVis
|
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
setIsMoving(true);
|
|
74
|
+
isMovingRef.current = true;
|
|
73
75
|
if (flameTimeoutRef.current) {
|
|
74
76
|
window.clearTimeout(flameTimeoutRef.current);
|
|
75
77
|
}
|
|
76
|
-
flameTimeoutRef.current = window.setTimeout(() =>
|
|
78
|
+
flameTimeoutRef.current = window.setTimeout(() => {
|
|
79
|
+
setIsMoving(false);
|
|
80
|
+
isMovingRef.current = false;
|
|
81
|
+
}, flameHideTimeout);
|
|
77
82
|
}, [threshold, flameHideTimeout, isVisible]);
|
|
78
83
|
const handleMouseOut = useCallback((e) => {
|
|
79
84
|
const rel = e.relatedTarget;
|
|
80
85
|
if (!rel || rel.nodeName === "HTML") {
|
|
81
86
|
setVisible(false);
|
|
82
87
|
setIsMoving(false);
|
|
88
|
+
isMovingRef.current = false;
|
|
83
89
|
}
|
|
84
90
|
}, []);
|
|
85
91
|
const handleVisibilityChange = useCallback(() => {
|
|
@@ -120,7 +126,8 @@ const RocketCursor = ({ size = 50, threshold = 10, flameHideTimeout = 300, isVis
|
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
if (flameRef.current) {
|
|
123
|
-
flameRef.current.style.opacity =
|
|
129
|
+
flameRef.current.style.opacity =
|
|
130
|
+
showFlame && isMovingRef.current ? "1" : "0";
|
|
124
131
|
}
|
|
125
132
|
rafRef.current = requestAnimationFrame(step);
|
|
126
133
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rocket-cursor-component",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "A customizable React component that replaces the cursor with an animated rocket, featuring rotation and flame effects.",
|
|
5
5
|
"main": "dist/rocket.Cursor.js",
|
|
6
6
|
"types": "dist/rocket.Cursor.d.ts",
|