rocket-cursor-component 1.0.8 → 1.1.0
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 +17 -11
- package/dist/rocket.Cursor.d.ts +1 -0
- package/dist/rocket.Cursor.js +65 -43
- package/package.json +42 -20
- package/assets/rocket-cursor-demo.gif +0 -0
- package/src/rocket.Cursor.tsx +0 -182
- package/tsconfig.json +0 -15
package/README.md
CHANGED
|
@@ -14,15 +14,15 @@ npm install rocket-cursor-component
|
|
|
14
14
|
|
|
15
15
|
Here's an example of how to use the `RocketCursor` component in your React app:
|
|
16
16
|
|
|
17
|
-
```
|
|
17
|
+
```tsx
|
|
18
18
|
import React from "react";
|
|
19
|
-
import RocketCursor from "rocket-cursor-component";
|
|
19
|
+
import RocketCursor from "rocket-cursor-component";
|
|
20
20
|
|
|
21
21
|
function App() {
|
|
22
22
|
return (
|
|
23
23
|
<div>
|
|
24
24
|
<h1>Your app content here</h1>
|
|
25
|
-
<RocketCursor size={60} threshold={15} />
|
|
25
|
+
<RocketCursor size={60} threshold={15} flameHideTimeout={300} />
|
|
26
26
|
</div>
|
|
27
27
|
);
|
|
28
28
|
}
|
|
@@ -32,29 +32,35 @@ export default App;
|
|
|
32
32
|
|
|
33
33
|
### Props
|
|
34
34
|
|
|
35
|
-
| Prop
|
|
36
|
-
|
|
|
37
|
-
| `size`
|
|
38
|
-
| `threshold`
|
|
39
|
-
| `isVisible`
|
|
35
|
+
| Prop | Type | Default | Description |
|
|
36
|
+
| ------------------ | ------- | ------- | ---------------------------------------------------------- |
|
|
37
|
+
| `size` | number | `50` | The size of the rocket cursor in pixels. |
|
|
38
|
+
| `threshold` | number | `10` | Minimum distance (pixels) to move before the rocket rotates. |
|
|
39
|
+
| `isVisible` | boolean | `true` | Initial visibility state of the rocket cursor. |
|
|
40
|
+
| `flameHideTimeout` | number | `300` | Time in milliseconds before the flame hides after stopping.|
|
|
40
41
|
|
|
41
42
|
## Features
|
|
42
43
|
|
|
43
44
|
- **Custom Cursor**: Replaces the default mouse cursor with a rocket that follows the cursor.
|
|
44
45
|
- **Rotation**: The rocket rotates in the direction of the cursor movement.
|
|
45
46
|
- **Flame Effect**: The rocket displays a flame animation when the cursor is moving.
|
|
46
|
-
- **Customizable**: Easily adjust the size, rotation threshold, and
|
|
47
|
+
- **Customizable**: Easily adjust the size, rotation threshold, visibility, and flame disappearance time.
|
|
47
48
|
- **Element-Specific Visibility**: Automatically hides the rocket cursor over elements with the class `no-rocket-cursor`.
|
|
48
49
|
|
|
49
50
|
## Demo
|
|
50
51
|
|
|
51
|
-
Here
|
|
52
|
+
Here's a demo of the Rocket Cursor in action:
|
|
52
53
|
|
|
53
54
|

|
|
54
55
|
|
|
55
56
|
## Changelog
|
|
56
57
|
|
|
57
|
-
### 1.0
|
|
58
|
+
### 1.1.0 (Planned/Current)
|
|
59
|
+
- Refactored SVG into separate components.
|
|
60
|
+
- Added `flameHideTimeout` prop for configurable flame duration.
|
|
61
|
+
- Improved code structure and efficiency.
|
|
62
|
+
|
|
63
|
+
### 1.0.9
|
|
58
64
|
|
|
59
65
|
- Added support to hide the Rocket Cursor on elements with the class `no-rocket-cursor`.
|
|
60
66
|
|
package/dist/rocket.Cursor.d.ts
CHANGED
package/dist/rocket.Cursor.js
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// Komponenta pro SVG Plamene
|
|
4
|
+
const FlameSvg = () => (React.createElement("g", { transform: "translate(1.2245, 350.449) rotate(45) scale(0.5, -0.5)" },
|
|
5
|
+
React.createElement("defs", null,
|
|
6
|
+
React.createElement("linearGradient", { id: "fireGradient", gradientUnits: "userSpaceOnUse", x1: "94.141", y1: "255", x2: "94.141", y2: "0.188" },
|
|
7
|
+
React.createElement("stop", { offset: "0", stopColor: "#ff4c0d" }),
|
|
8
|
+
React.createElement("stop", { offset: "1", stopColor: "#fc9502" }))),
|
|
9
|
+
React.createElement("path", { d: "M187.899,164.809 C185.803,214.868 144.574,254.812 94.000,254.812 C42.085,254.812 -0.000,211.312 -0.000,160.812 C-0.000,154.062 -0.121,140.572 10.000,117.812 C16.057,104.191 19.856,95.634 22.000,87.812 C23.178,83.513 25.469,76.683 32.000,87.812 C35.851,94.374 36.000,103.812 36.000,103.812 C36.000,103.812 50.328,92.817 60.000,71.812 C74.179,41.019 62.866,22.612 59.000,9.812 C57.662,5.384 56.822,-2.574 66.000,0.812 C75.352,4.263 100.076,21.570 113.000,39.812 C131.445,65.847 138.000,90.812 138.000,90.812 C138.000,90.812 143.906,83.482 146.000,75.812 C148.365,67.151 148.400,58.573 155.999,67.813 C163.226,76.600 173.959,93.113 180.000,108.812 C190.969,137.321 187.899,164.809 187.899,164.809 Z", fill: "url(#fireGradient)", fillRule: "evenodd" }),
|
|
10
|
+
React.createElement("path", { d: "M94.000,254.812 C58.101,254.812 29.000,225.711 29.000,189.812 C29.000,168.151 37.729,155.000 55.896,137.166 C67.528,125.747 78.415,111.722 83.042,102.172 C83.953,100.292 86.026,90.495 94.019,101.966 C98.212,107.982 104.785,118.681 109.000,127.812 C116.266,143.555 118.000,158.812 118.000,158.812 C118.000,158.812 125.121,154.616 130.000,143.812 C131.573,140.330 134.753,127.148 143.643,140.328 C150.166,150.000 159.127,167.390 159.000,189.812 C159.000,225.711 129.898,254.812 94.000,254.812 Z", fill: "#fc9502", fillRule: "evenodd" }),
|
|
11
|
+
React.createElement("path", { d: "M95.000,183.812 C104.250,183.812 104.250,200.941 116.000,223.812 C123.824,239.041 112.121,254.812 95.000,254.812 C77.879,254.812 69.000,240.933 69.000,223.812 C69.000,206.692 85.750,183.812 95.000,183.812 Z", fill: "#fce202", fillRule: "evenodd" })));
|
|
12
|
+
// Komponenta pro SVG Rakety
|
|
13
|
+
const RocketSvg = () => (React.createElement("g", { transform: "translate(0, 0)" },
|
|
14
|
+
React.createElement("path", { style: { fill: "#FF7124" }, d: "M399.76,16.699c10.12,37.84,8.67,78.13-4.34,115.28h-0.01L284.48,21.049v-0.01 C321.63,8.029,361.92,6.579,399.76,16.699z" }),
|
|
15
|
+
React.createElement("path", { style: { fill: "#F2D59F" }, d: "M90.21,207.929l87.14-101.42h0.01l33.71-39.24c21.43-21.43,46.6-36.84,73.41-46.23v0.01 l110.93,110.93h0.01c-9.39,26.81-24.8,51.98-46.23,73.41l-39.24,33.71l-101.43,87.14l-29.57-29.57l-29.58-29.58l-29.58-29.58 L90.21,207.929z M296.11,193.399c20.18-20.17,20.18-52.89,0-73.06c-20.17-20.18-52.89-20.18-73.06,0 c-20.18,20.17-20.18,52.89,0,73.06C243.22,213.579,275.94,213.579,296.11,193.399z" }),
|
|
16
|
+
React.createElement("path", { style: { fill: "#F2D59F" }, d: "M309.95,239.099c1.74,45.6-14.8,91.78-49.61,126.59c-10.69,10.68-22.44,19.65-34.93,26.89 l-16.89-66.34L309.95,239.099z" }),
|
|
17
|
+
React.createElement("path", { style: { fill: "#8ECAC1" }, d: "M296.11,120.339c20.18,20.17,20.18,52.89,0,73.06c-20.17,20.18-52.89,20.18-73.06,0 c-20.18-20.17-20.18-52.89,0-73.06C243.22,100.159,275.94,100.159,296.11,120.339z" }),
|
|
18
|
+
React.createElement("path", { style: { fill: "#E6B263" }, d: "M208.52,326.239l-39.94,14.71c-10.98,4.05-23.31,1.34-31.58-6.94l-6.85-6.85l48.8-30.49 L208.52,326.239z" }),
|
|
19
|
+
React.createElement("polygon", { style: { fill: "#E6B263" }, points: "178.95,296.669 130.15,327.159 130.14,327.159 109.72,306.739 149.37,267.089" }),
|
|
20
|
+
React.createElement("path", { style: { fill: "#F2D59F" }, d: "M177.35,106.509l-87.14,101.42l-66.33-16.88c7.24-12.49,16.21-24.24,26.89-34.93 C85.58,121.309,131.74,104.769,177.35,106.509z" }),
|
|
21
|
+
React.createElement("polygon", { style: { fill: "#E6B263" }, points: "149.37,267.089 109.72,306.739 89.3,286.309 119.79,237.509" }),
|
|
22
|
+
React.createElement("path", { style: { fill: "#E6B263" }, d: "M119.79,237.509l-30.49,48.8l-6.86-6.85c-8.27-8.28-10.98-20.6-6.94-31.58l14.71-39.95 L119.79,237.509z" })));
|
|
23
|
+
const RocketCursor = ({ size = 50, threshold = 10, isVisible = true, flameHideTimeout = 300, }) => {
|
|
24
|
+
const [position, setPosition] = useState({ x: -size, y: -size });
|
|
5
25
|
const [angle, setAngle] = useState(0);
|
|
6
|
-
const [isMoving, setIsMoving] = useState(
|
|
26
|
+
const [isMoving, setIsMoving] = useState(false);
|
|
7
27
|
const [visible, setVisible] = useState(isVisible);
|
|
8
28
|
const lastSignificantPosition = useRef({ x: 0, y: 0 });
|
|
9
29
|
const lastMoveTimestamp = useRef(Date.now());
|
|
30
|
+
const timeoutRef = useRef(null);
|
|
10
31
|
const handleMouseMove = useCallback((e) => {
|
|
32
|
+
const target = e.target;
|
|
33
|
+
if (target.closest(".no-rocket-cursor")) {
|
|
34
|
+
setVisible(false);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
setVisible(true);
|
|
11
38
|
const currentPosition = { x: e.clientX, y: e.clientY };
|
|
12
39
|
setPosition(currentPosition);
|
|
13
40
|
const dx = currentPosition.x - lastSignificantPosition.current.x;
|
|
@@ -18,10 +45,15 @@ const RocketCursor = ({ size = 50, threshold = 10, isVisible = true, }) => {
|
|
|
18
45
|
setAngle(newAngle);
|
|
19
46
|
lastSignificantPosition.current = currentPosition;
|
|
20
47
|
}
|
|
21
|
-
lastMoveTimestamp.current = Date.now();
|
|
22
48
|
setIsMoving(true);
|
|
23
|
-
|
|
24
|
-
|
|
49
|
+
lastMoveTimestamp.current = Date.now();
|
|
50
|
+
if (timeoutRef.current) {
|
|
51
|
+
clearTimeout(timeoutRef.current);
|
|
52
|
+
}
|
|
53
|
+
timeoutRef.current = setTimeout(() => {
|
|
54
|
+
setIsMoving(false);
|
|
55
|
+
}, flameHideTimeout);
|
|
56
|
+
}, [threshold, flameHideTimeout]);
|
|
25
57
|
const handleMouseOut = (e) => {
|
|
26
58
|
if (!e.relatedTarget ||
|
|
27
59
|
e.relatedTarget.nodeName === "HTML") {
|
|
@@ -34,13 +66,10 @@ const RocketCursor = ({ size = 50, threshold = 10, isVisible = true, }) => {
|
|
|
34
66
|
}
|
|
35
67
|
};
|
|
36
68
|
useEffect(() => {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const intervalId = setInterval(checkIfStopped, 100);
|
|
69
|
+
const initialX = window.innerWidth / 2;
|
|
70
|
+
const initialY = window.innerHeight / 2;
|
|
71
|
+
setPosition({ x: initialX, y: initialY });
|
|
72
|
+
lastSignificantPosition.current = { x: initialX, y: initialY };
|
|
44
73
|
window.addEventListener("mousemove", handleMouseMove);
|
|
45
74
|
document.addEventListener("mouseout", handleMouseOut);
|
|
46
75
|
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
@@ -48,40 +77,33 @@ const RocketCursor = ({ size = 50, threshold = 10, isVisible = true, }) => {
|
|
|
48
77
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
49
78
|
document.removeEventListener("mouseout", handleMouseOut);
|
|
50
79
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
51
|
-
|
|
80
|
+
if (timeoutRef.current) {
|
|
81
|
+
clearTimeout(timeoutRef.current);
|
|
82
|
+
}
|
|
52
83
|
};
|
|
53
84
|
}, [handleMouseMove]);
|
|
85
|
+
const wrapperStyle = {
|
|
86
|
+
position: "fixed",
|
|
87
|
+
left: position.x,
|
|
88
|
+
top: position.y,
|
|
89
|
+
transform: `translate(-50%, -50%) rotate(${angle}deg)`,
|
|
90
|
+
pointerEvents: "none",
|
|
91
|
+
zIndex: 9999,
|
|
92
|
+
width: `${size}px`,
|
|
93
|
+
height: `${size * 1.5}px`,
|
|
94
|
+
transition: 'left 0.05s linear, top 0.05s linear',
|
|
95
|
+
};
|
|
96
|
+
const svgStyle = {
|
|
97
|
+
width: "100%",
|
|
98
|
+
height: "100%",
|
|
99
|
+
display: 'block',
|
|
100
|
+
};
|
|
54
101
|
if (!isVisible || !visible) {
|
|
55
102
|
return null;
|
|
56
103
|
}
|
|
57
|
-
return (React.createElement("div", { style:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
transform: `translate(-50%, -50%) rotate(${angle}deg)`,
|
|
62
|
-
pointerEvents: "none",
|
|
63
|
-
zIndex: 9999,
|
|
64
|
-
width: `${size}px`,
|
|
65
|
-
height: `${size * 1.5}px`,
|
|
66
|
-
} },
|
|
67
|
-
React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 416.449 516.449", width: "100%", height: "100%" },
|
|
68
|
-
React.createElement("defs", null,
|
|
69
|
-
React.createElement("linearGradient", { id: "fireGradient", gradientUnits: "userSpaceOnUse", x1: "94.141", y1: "255", x2: "94.141", y2: "0.188" },
|
|
70
|
-
React.createElement("stop", { offset: "0", stopColor: "#ff4c0d" }),
|
|
71
|
-
React.createElement("stop", { offset: "1", stopColor: "#fc9502" }))),
|
|
72
|
-
isMoving && (React.createElement("g", { transform: "translate(1.2245, 350.449) rotate(45) scale(0.5, -0.5)" },
|
|
73
|
-
React.createElement("path", { d: "M187.899,164.809 C185.803,214.868 144.574,254.812 94.000,254.812 C42.085,254.812 -0.000,211.312 -0.000,160.812 C-0.000,154.062 -0.121,140.572 10.000,117.812 C16.057,104.191 19.856,95.634 22.000,87.812 C23.178,83.513 25.469,76.683 32.000,87.812 C35.851,94.374 36.000,103.812 36.000,103.812 C36.000,103.812 50.328,92.817 60.000,71.812 C74.179,41.019 62.866,22.612 59.000,9.812 C57.662,5.384 56.822,-2.574 66.000,0.812 C75.352,4.263 100.076,21.570 113.000,39.812 C131.445,65.847 138.000,90.812 138.000,90.812 C138.000,90.812 143.906,83.482 146.000,75.812 C148.365,67.151 148.400,58.573 155.999,67.813 C163.226,76.600 173.959,93.113 180.000,108.812 C190.969,137.321 187.899,164.809 187.899,164.809 Z", fill: "url(#fireGradient)", fillRule: "evenodd" }),
|
|
74
|
-
React.createElement("path", { d: "M94.000,254.812 C58.101,254.812 29.000,225.711 29.000,189.812 C29.000,168.151 37.729,155.000 55.896,137.166 C67.528,125.747 78.415,111.722 83.042,102.172 C83.953,100.292 86.026,90.495 94.019,101.966 C98.212,107.982 104.785,118.681 109.000,127.812 C116.266,143.555 118.000,158.812 118.000,158.812 C118.000,158.812 125.121,154.616 130.000,143.812 C131.573,140.330 134.753,127.148 143.643,140.328 C150.166,150.000 159.127,167.390 159.000,189.812 C159.000,225.711 129.898,254.812 94.000,254.812 Z", fill: "#fc9502", fillRule: "evenodd" }),
|
|
75
|
-
React.createElement("path", { d: "M95.000,183.812 C104.250,183.812 104.250,200.941 116.000,223.812 C123.824,239.041 112.121,254.812 95.000,254.812 C77.879,254.812 69.000,240.933 69.000,223.812 C69.000,206.692 85.750,183.812 95.000,183.812 Z", fill: "#fce202", fillRule: "evenodd" }))),
|
|
76
|
-
React.createElement("g", { transform: "translate(0, 0)" },
|
|
77
|
-
React.createElement("path", { style: { fill: "#FF7124" }, d: "M399.76,16.699c10.12,37.84,8.67,78.13-4.34,115.28h-0.01L284.48,21.049v-0.01 C321.63,8.029,361.92,6.579,399.76,16.699z" }),
|
|
78
|
-
React.createElement("path", { style: { fill: "#F2D59F" }, d: "M90.21,207.929l87.14-101.42h0.01l33.71-39.24c21.43-21.43,46.6-36.84,73.41-46.23v0.01 l110.93,110.93h0.01c-9.39,26.81-24.8,51.98-46.23,73.41l-39.24,33.71l-101.43,87.14l-29.57-29.57l-29.58-29.58l-29.58-29.58 L90.21,207.929z M296.11,193.399c20.18-20.17,20.18-52.89,0-73.06c-20.17-20.18-52.89-20.18-73.06,0 c-20.18,20.17-20.18,52.89,0,73.06C243.22,213.579,275.94,213.579,296.11,193.399z" }),
|
|
79
|
-
React.createElement("path", { style: { fill: "#F2D59F" }, d: "M309.95,239.099c1.74,45.6-14.8,91.78-49.61,126.59c-10.69,10.68-22.44,19.65-34.93,26.89 l-16.89-66.34L309.95,239.099z" }),
|
|
80
|
-
React.createElement("path", { style: { fill: "#8ECAC1" }, d: "M296.11,120.339c20.18,20.17,20.18,52.89,0,73.06c-20.17,20.18-52.89,20.18-73.06,0 c-20.18-20.17-20.18-52.89,0-73.06C243.22,100.159,275.94,100.159,296.11,120.339z" }),
|
|
81
|
-
React.createElement("path", { style: { fill: "#E6B263" }, d: "M208.52,326.239l-39.94,14.71c-10.98,4.05-23.31,1.34-31.58-6.94l-6.85-6.85l48.8-30.49 L208.52,326.239z" }),
|
|
82
|
-
React.createElement("polygon", { style: { fill: "#E6B263" }, points: "178.95,296.669 130.15,327.159 130.14,327.159 109.72,306.739 149.37,267.089" }),
|
|
83
|
-
React.createElement("path", { style: { fill: "#F2D59F" }, d: "M177.35,106.509l-87.14,101.42l-66.33-16.88c7.24-12.49,16.21-24.24,26.89-34.93 C85.58,121.309,131.74,104.769,177.35,106.509z" }),
|
|
84
|
-
React.createElement("polygon", { style: { fill: "#E6B263" }, points: "149.37,267.089 109.72,306.739 89.3,286.309 119.79,237.509" }),
|
|
85
|
-
React.createElement("path", { style: { fill: "#E6B263" }, d: "M119.79,237.509l-30.49,48.8l-6.86-6.85c-8.27-8.28-10.98-20.6-6.94-31.58l14.71-39.95 L119.79,237.509z" })))));
|
|
104
|
+
return (React.createElement("div", { style: wrapperStyle },
|
|
105
|
+
React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 416.449 516.449", style: svgStyle },
|
|
106
|
+
isMoving && React.createElement(FlameSvg, null),
|
|
107
|
+
React.createElement(RocketSvg, null))));
|
|
86
108
|
};
|
|
87
109
|
export default RocketCursor;
|
package/package.json
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rocket-cursor-component",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "A customizable React component that replaces the cursor with an animated rocket.",
|
|
5
|
-
"main": "dist/rocket.Cursor.js",
|
|
6
|
-
"types": "dist/rocket.Cursor.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "rocket-cursor-component",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "A customizable React component that replaces the cursor with an animated rocket, featuring rotation and flame effects.",
|
|
5
|
+
"main": "dist/rocket.Cursor.js",
|
|
6
|
+
"types": "dist/rocket.Cursor.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/No898/RocketCursor.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"react",
|
|
22
|
+
"cursor",
|
|
23
|
+
"rocket",
|
|
24
|
+
"component",
|
|
25
|
+
"typescript",
|
|
26
|
+
"animation"
|
|
27
|
+
],
|
|
28
|
+
"author": "Tomas Dinh",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": ">=16.8.0",
|
|
32
|
+
"react-dom": ">=16.8.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.15.3",
|
|
36
|
+
"@types/react": "^18.3.20",
|
|
37
|
+
"@types/react-dom": "^18.3.0",
|
|
38
|
+
"react": ">=16.8.0",
|
|
39
|
+
"react-dom": ">=16.8.0",
|
|
40
|
+
"typescript": "^4.0.0"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
Binary file
|
package/src/rocket.Cursor.tsx
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback, useRef } from "react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
interface RocketCursorProps {
|
|
5
|
-
size?: number;
|
|
6
|
-
threshold?: number;
|
|
7
|
-
isVisible?: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const RocketCursor: React.FC<RocketCursorProps> = ({
|
|
11
|
-
size = 50,
|
|
12
|
-
threshold = 10,
|
|
13
|
-
isVisible = true,
|
|
14
|
-
}) => {
|
|
15
|
-
const [position, setPosition] = useState({ x: 0, y: 0 });
|
|
16
|
-
const [angle, setAngle] = useState(0);
|
|
17
|
-
const [isMoving, setIsMoving] = useState(true);
|
|
18
|
-
const [visible, setVisible] = useState(isVisible);
|
|
19
|
-
const lastSignificantPosition = useRef({ x: 0, y: 0 });
|
|
20
|
-
const lastMoveTimestamp = useRef(Date.now());
|
|
21
|
-
|
|
22
|
-
const handleMouseMove = useCallback(
|
|
23
|
-
(e: { clientX: any; clientY: any }) => {
|
|
24
|
-
const currentPosition = { x: e.clientX, y: e.clientY };
|
|
25
|
-
setPosition(currentPosition);
|
|
26
|
-
|
|
27
|
-
const dx = currentPosition.x - lastSignificantPosition.current.x;
|
|
28
|
-
const dy = currentPosition.y - lastSignificantPosition.current.y;
|
|
29
|
-
|
|
30
|
-
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
31
|
-
|
|
32
|
-
if (distance > threshold) {
|
|
33
|
-
const newAngle = Math.atan2(dy, dx) * (180 / Math.PI) + 45;
|
|
34
|
-
setAngle(newAngle);
|
|
35
|
-
lastSignificantPosition.current = currentPosition;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
lastMoveTimestamp.current = Date.now();
|
|
39
|
-
setIsMoving(true);
|
|
40
|
-
setVisible(true);
|
|
41
|
-
},
|
|
42
|
-
[threshold]
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const handleMouseOut = (e: MouseEvent) => {
|
|
46
|
-
if (
|
|
47
|
-
!e.relatedTarget ||
|
|
48
|
-
(e.relatedTarget as HTMLElement).nodeName === "HTML"
|
|
49
|
-
) {
|
|
50
|
-
setVisible(false);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const handleVisibilityChange = () => {
|
|
55
|
-
if (document.visibilityState === "visible") {
|
|
56
|
-
setVisible(true);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
const checkIfStopped = () => {
|
|
62
|
-
const now = Date.now();
|
|
63
|
-
if (now - lastMoveTimestamp.current > 300) {
|
|
64
|
-
setIsMoving(false);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const intervalId = setInterval(checkIfStopped, 100);
|
|
69
|
-
|
|
70
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
71
|
-
document.addEventListener("mouseout", handleMouseOut);
|
|
72
|
-
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
73
|
-
|
|
74
|
-
return () => {
|
|
75
|
-
window.removeEventListener("mousemove", handleMouseMove);
|
|
76
|
-
document.removeEventListener("mouseout", handleMouseOut);
|
|
77
|
-
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
78
|
-
clearInterval(intervalId);
|
|
79
|
-
};
|
|
80
|
-
}, [handleMouseMove]);
|
|
81
|
-
|
|
82
|
-
if (!isVisible || !visible) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<div
|
|
88
|
-
style={{
|
|
89
|
-
position: "fixed",
|
|
90
|
-
left: position.x,
|
|
91
|
-
top: position.y,
|
|
92
|
-
transform: `translate(-50%, -50%) rotate(${angle}deg)`,
|
|
93
|
-
pointerEvents: "none",
|
|
94
|
-
zIndex: 9999,
|
|
95
|
-
width: `${size}px`,
|
|
96
|
-
height: `${size * 1.5}px`,
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
<svg
|
|
100
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
101
|
-
viewBox="0 0 416.449 516.449"
|
|
102
|
-
width="100%"
|
|
103
|
-
height="100%"
|
|
104
|
-
>
|
|
105
|
-
<defs>
|
|
106
|
-
<linearGradient
|
|
107
|
-
id="fireGradient"
|
|
108
|
-
gradientUnits="userSpaceOnUse"
|
|
109
|
-
x1="94.141"
|
|
110
|
-
y1="255"
|
|
111
|
-
x2="94.141"
|
|
112
|
-
y2="0.188"
|
|
113
|
-
>
|
|
114
|
-
<stop offset="0" stopColor="#ff4c0d" />
|
|
115
|
-
<stop offset="1" stopColor="#fc9502" />
|
|
116
|
-
</linearGradient>
|
|
117
|
-
</defs>
|
|
118
|
-
|
|
119
|
-
{isMoving && (
|
|
120
|
-
<g transform="translate(1.2245, 350.449) rotate(45) scale(0.5, -0.5)">
|
|
121
|
-
<path
|
|
122
|
-
d="M187.899,164.809 C185.803,214.868 144.574,254.812 94.000,254.812 C42.085,254.812 -0.000,211.312 -0.000,160.812 C-0.000,154.062 -0.121,140.572 10.000,117.812 C16.057,104.191 19.856,95.634 22.000,87.812 C23.178,83.513 25.469,76.683 32.000,87.812 C35.851,94.374 36.000,103.812 36.000,103.812 C36.000,103.812 50.328,92.817 60.000,71.812 C74.179,41.019 62.866,22.612 59.000,9.812 C57.662,5.384 56.822,-2.574 66.000,0.812 C75.352,4.263 100.076,21.570 113.000,39.812 C131.445,65.847 138.000,90.812 138.000,90.812 C138.000,90.812 143.906,83.482 146.000,75.812 C148.365,67.151 148.400,58.573 155.999,67.813 C163.226,76.600 173.959,93.113 180.000,108.812 C190.969,137.321 187.899,164.809 187.899,164.809 Z"
|
|
123
|
-
fill="url(#fireGradient)"
|
|
124
|
-
fillRule="evenodd"
|
|
125
|
-
/>
|
|
126
|
-
<path
|
|
127
|
-
d="M94.000,254.812 C58.101,254.812 29.000,225.711 29.000,189.812 C29.000,168.151 37.729,155.000 55.896,137.166 C67.528,125.747 78.415,111.722 83.042,102.172 C83.953,100.292 86.026,90.495 94.019,101.966 C98.212,107.982 104.785,118.681 109.000,127.812 C116.266,143.555 118.000,158.812 118.000,158.812 C118.000,158.812 125.121,154.616 130.000,143.812 C131.573,140.330 134.753,127.148 143.643,140.328 C150.166,150.000 159.127,167.390 159.000,189.812 C159.000,225.711 129.898,254.812 94.000,254.812 Z"
|
|
128
|
-
fill="#fc9502"
|
|
129
|
-
fillRule="evenodd"
|
|
130
|
-
/>
|
|
131
|
-
<path
|
|
132
|
-
d="M95.000,183.812 C104.250,183.812 104.250,200.941 116.000,223.812 C123.824,239.041 112.121,254.812 95.000,254.812 C77.879,254.812 69.000,240.933 69.000,223.812 C69.000,206.692 85.750,183.812 95.000,183.812 Z"
|
|
133
|
-
fill="#fce202"
|
|
134
|
-
fillRule="evenodd"
|
|
135
|
-
/>
|
|
136
|
-
</g>
|
|
137
|
-
)}
|
|
138
|
-
|
|
139
|
-
<g transform="translate(0, 0)">
|
|
140
|
-
<path
|
|
141
|
-
style={{ fill: "#FF7124" }}
|
|
142
|
-
d="M399.76,16.699c10.12,37.84,8.67,78.13-4.34,115.28h-0.01L284.48,21.049v-0.01 C321.63,8.029,361.92,6.579,399.76,16.699z"
|
|
143
|
-
/>
|
|
144
|
-
<path
|
|
145
|
-
style={{ fill: "#F2D59F" }}
|
|
146
|
-
d="M90.21,207.929l87.14-101.42h0.01l33.71-39.24c21.43-21.43,46.6-36.84,73.41-46.23v0.01 l110.93,110.93h0.01c-9.39,26.81-24.8,51.98-46.23,73.41l-39.24,33.71l-101.43,87.14l-29.57-29.57l-29.58-29.58l-29.58-29.58 L90.21,207.929z M296.11,193.399c20.18-20.17,20.18-52.89,0-73.06c-20.17-20.18-52.89-20.18-73.06,0 c-20.18,20.17-20.18,52.89,0,73.06C243.22,213.579,275.94,213.579,296.11,193.399z"
|
|
147
|
-
/>
|
|
148
|
-
<path
|
|
149
|
-
style={{ fill: "#F2D59F" }}
|
|
150
|
-
d="M309.95,239.099c1.74,45.6-14.8,91.78-49.61,126.59c-10.69,10.68-22.44,19.65-34.93,26.89 l-16.89-66.34L309.95,239.099z"
|
|
151
|
-
/>
|
|
152
|
-
<path
|
|
153
|
-
style={{ fill: "#8ECAC1" }}
|
|
154
|
-
d="M296.11,120.339c20.18,20.17,20.18,52.89,0,73.06c-20.17,20.18-52.89,20.18-73.06,0 c-20.18-20.17-20.18-52.89,0-73.06C243.22,100.159,275.94,100.159,296.11,120.339z"
|
|
155
|
-
/>
|
|
156
|
-
<path
|
|
157
|
-
style={{ fill: "#E6B263" }}
|
|
158
|
-
d="M208.52,326.239l-39.94,14.71c-10.98,4.05-23.31,1.34-31.58-6.94l-6.85-6.85l48.8-30.49 L208.52,326.239z"
|
|
159
|
-
/>
|
|
160
|
-
<polygon
|
|
161
|
-
style={{ fill: "#E6B263" }}
|
|
162
|
-
points="178.95,296.669 130.15,327.159 130.14,327.159 109.72,306.739 149.37,267.089"
|
|
163
|
-
/>
|
|
164
|
-
<path
|
|
165
|
-
style={{ fill: "#F2D59F" }}
|
|
166
|
-
d="M177.35,106.509l-87.14,101.42l-66.33-16.88c7.24-12.49,16.21-24.24,26.89-34.93 C85.58,121.309,131.74,104.769,177.35,106.509z"
|
|
167
|
-
/>
|
|
168
|
-
<polygon
|
|
169
|
-
style={{ fill: "#E6B263" }}
|
|
170
|
-
points="149.37,267.089 109.72,306.739 89.3,286.309 119.79,237.509"
|
|
171
|
-
/>
|
|
172
|
-
<path
|
|
173
|
-
style={{ fill: "#E6B263" }}
|
|
174
|
-
d="M119.79,237.509l-30.49,48.8l-6.86-6.85c-8.27-8.28-10.98-20.6-6.94-31.58l14.71-39.95 L119.79,237.509z"
|
|
175
|
-
/>
|
|
176
|
-
</g>
|
|
177
|
-
</svg>
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
export default RocketCursor;
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES6", // Target ES6 or later for modern JavaScript compatibility
|
|
4
|
-
"module": "ES6", // Use ES6 modules
|
|
5
|
-
"jsx": "react", // Allow JSX in .tsx files
|
|
6
|
-
"declaration": true, // Generate .d.ts files for TypeScript consumers
|
|
7
|
-
"outDir": "./dist", // Output directory for compiled files
|
|
8
|
-
"strict": true, // Enable strict type checking
|
|
9
|
-
"moduleResolution": "node", // Resolve modules using Node.js style
|
|
10
|
-
"esModuleInterop": true, // Compatibility with CommonJS modules
|
|
11
|
-
"skipLibCheck": true // Skip type checking for libraries
|
|
12
|
-
},
|
|
13
|
-
"include": ["./src"], // Include all files in the src directory
|
|
14
|
-
"exclude": ["node_modules", "**/*.test.tsx"] // Exclude tests and node_modules
|
|
15
|
-
}
|