@stianlarsen/react-light-beam 1.0.7 → 1.0.9
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/dist/css/lightBeam.module.css +3 -2
- package/dist/index.js +19 -5
- package/package.json +5 -6
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
.react__light__beam {
|
|
2
2
|
height: 500px;
|
|
3
3
|
width: 100vw;
|
|
4
|
-
transition: all 0.
|
|
5
|
-
will-change:
|
|
4
|
+
transition: all 0.25s ease;
|
|
5
|
+
will-change: all;
|
|
6
6
|
-webkit-user-select: none;
|
|
7
7
|
-moz-user-select: none;
|
|
8
8
|
user-select: none;
|
|
9
9
|
pointer-events: none;
|
|
10
|
+
-webkit-transition: all 0.25s ease;
|
|
10
11
|
}/*# sourceMappingURL=lightBeam.module.css.map */
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@ invert = false, id = undefined, onLoaded = undefined, }) => {
|
|
|
46
46
|
onLoaded && onLoaded();
|
|
47
47
|
}, []);
|
|
48
48
|
(0, react_1.useEffect)(() => {
|
|
49
|
-
if (bodyElement) {
|
|
49
|
+
if (bodyElement && typeof window !== "undefined") {
|
|
50
50
|
const handleScroll = () => {
|
|
51
51
|
if (elementRef.current) {
|
|
52
52
|
const rect = elementRef.current.getBoundingClientRect();
|
|
@@ -65,13 +65,14 @@ invert = false, id = undefined, onLoaded = undefined, }) => {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
// Attach scroll and resize event listeners
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const handleScrollThrottled = throttle(handleScroll); // Approx 60fps
|
|
69
|
+
bodyElement.addEventListener("scroll", handleScrollThrottled);
|
|
70
|
+
window.addEventListener("resize", handleScrollThrottled);
|
|
70
71
|
// Initial call to handleScroll to set initial state
|
|
71
72
|
handleScroll();
|
|
72
73
|
return () => {
|
|
73
|
-
bodyElement.removeEventListener("scroll",
|
|
74
|
-
window.removeEventListener("resize",
|
|
74
|
+
bodyElement.removeEventListener("scroll", handleScrollThrottled);
|
|
75
|
+
window.removeEventListener("resize", handleScrollThrottled);
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
}, [bodyElement, inViewProgress, opacity]);
|
|
@@ -91,6 +92,19 @@ invert = false, id = undefined, onLoaded = undefined, }) => {
|
|
|
91
92
|
opacity: opacity,
|
|
92
93
|
maskImage: maskImage,
|
|
93
94
|
WebkitMaskImage: maskImage,
|
|
95
|
+
willChange: "background, opacity",
|
|
94
96
|
}, ref: elementRef, id: id, className: `lightBeam ${className} ${lightBeam_module_css_1.default.react__light__beam}` }));
|
|
95
97
|
};
|
|
96
98
|
exports.LightBeam = LightBeam;
|
|
99
|
+
const throttle = (func) => {
|
|
100
|
+
let ticking = false;
|
|
101
|
+
return function (...args) {
|
|
102
|
+
if (!ticking) {
|
|
103
|
+
requestAnimationFrame(() => {
|
|
104
|
+
func.apply(this, args);
|
|
105
|
+
ticking = false;
|
|
106
|
+
});
|
|
107
|
+
ticking = true;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stianlarsen/react-light-beam",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "A customizable React component that creates a light beam effect using conic gradients. Supports dark mode and various customization options.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,9 +38,10 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/stianalars1/react-light-beam#readme",
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"framer-motion": "^11.
|
|
41
|
+
"framer-motion": "^11.11.1",
|
|
42
42
|
"react": "^18",
|
|
43
|
-
"react-dom": "^18"
|
|
43
|
+
"react-dom": "^18",
|
|
44
|
+
"@emotion/is-prop-valid": "^1.3.1"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/react": "^18",
|
|
@@ -49,8 +50,6 @@
|
|
|
49
50
|
"typescript": "^5.5.4"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"framer-motion": "^11.
|
|
53
|
-
"react": "^18",
|
|
54
|
-
"react-dom": "^18"
|
|
53
|
+
"framer-motion": "^11.11.1"
|
|
55
54
|
}
|
|
56
55
|
}
|