@stackvibe-studio/motion 0.3.0 → 0.3.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/dist/components/magnetic.d.ts +5 -1
- package/dist/components/tilt-card.d.ts +6 -1
- package/dist/index.cjs +28 -12
- package/dist/index.js +28 -12
- package/package.json +19 -1
|
@@ -2,6 +2,10 @@ import { type ReactNode } from 'react';
|
|
|
2
2
|
export interface MagneticProps {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
strength?: number;
|
|
5
|
+
damping?: number;
|
|
6
|
+
stiffness?: number;
|
|
7
|
+
mass?: number;
|
|
8
|
+
disabled?: boolean;
|
|
5
9
|
className?: string;
|
|
6
10
|
}
|
|
7
|
-
export declare function Magnetic({ children, strength, className }: MagneticProps): import("react").JSX.Element;
|
|
11
|
+
export declare function Magnetic({ children, strength, damping, stiffness, mass, disabled, className, }: MagneticProps): import("react").JSX.Element;
|
|
@@ -2,7 +2,12 @@ import { type ReactNode } from 'react';
|
|
|
2
2
|
export interface TiltCardProps {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
maxTilt?: number;
|
|
5
|
+
perspective?: number;
|
|
6
|
+
scale?: number;
|
|
5
7
|
glare?: boolean;
|
|
8
|
+
glareOpacity?: number;
|
|
9
|
+
glareColor?: string;
|
|
10
|
+
speed?: number;
|
|
6
11
|
className?: string;
|
|
7
12
|
}
|
|
8
|
-
export declare function TiltCard({ children, maxTilt, glare, className, }: TiltCardProps): import("react").JSX.Element;
|
|
13
|
+
export declare function TiltCard({ children, maxTilt, perspective, scale, glare, glareOpacity, glareColor, speed, className, }: TiltCardProps): import("react").JSX.Element;
|
package/dist/index.cjs
CHANGED
|
@@ -59,15 +59,23 @@ function FadeInSection({
|
|
|
59
59
|
var import_react2 = require("motion/react");
|
|
60
60
|
var import_react3 = require("react");
|
|
61
61
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
62
|
-
function Magnetic({
|
|
62
|
+
function Magnetic({
|
|
63
|
+
children,
|
|
64
|
+
strength = 0.35,
|
|
65
|
+
damping = 15,
|
|
66
|
+
stiffness = 150,
|
|
67
|
+
mass = 0.1,
|
|
68
|
+
disabled = false,
|
|
69
|
+
className = ""
|
|
70
|
+
}) {
|
|
63
71
|
const ref = (0, import_react3.useRef)(null);
|
|
64
72
|
const x = (0, import_react2.useMotionValue)(0);
|
|
65
73
|
const y = (0, import_react2.useMotionValue)(0);
|
|
66
|
-
const springConfig = { damping
|
|
74
|
+
const springConfig = { damping, stiffness, mass };
|
|
67
75
|
const springX = (0, import_react2.useSpring)(x, springConfig);
|
|
68
76
|
const springY = (0, import_react2.useSpring)(y, springConfig);
|
|
69
77
|
const handleMouseMove = (e) => {
|
|
70
|
-
if (!ref.current) return;
|
|
78
|
+
if (disabled || !ref.current) return;
|
|
71
79
|
const { clientX, clientY } = e;
|
|
72
80
|
const { left, top, width, height } = ref.current.getBoundingClientRect();
|
|
73
81
|
const middleX = clientX - (left + width / 2);
|
|
@@ -86,7 +94,7 @@ function Magnetic({ children, strength = 0.35, className = "" }) {
|
|
|
86
94
|
onMouseMove: handleMouseMove,
|
|
87
95
|
onMouseLeave: handleMouseLeave,
|
|
88
96
|
style: { x: springX, y: springY },
|
|
89
|
-
className: ["inline-block
|
|
97
|
+
className: ["inline-block", className].join(" "),
|
|
90
98
|
children
|
|
91
99
|
}
|
|
92
100
|
);
|
|
@@ -241,12 +249,18 @@ var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
|
241
249
|
function TiltCard({
|
|
242
250
|
children,
|
|
243
251
|
maxTilt = 15,
|
|
252
|
+
perspective = 1e3,
|
|
253
|
+
scale = 1.02,
|
|
244
254
|
glare = true,
|
|
255
|
+
glareOpacity = 0.25,
|
|
256
|
+
glareColor = "rgba(255, 255, 255, 0.4)",
|
|
257
|
+
speed = 300,
|
|
245
258
|
className = ""
|
|
246
259
|
}) {
|
|
247
260
|
const cardRef = (0, import_react7.useRef)(null);
|
|
248
261
|
const [rotateX, setRotateX] = (0, import_react7.useState)(0);
|
|
249
262
|
const [rotateY, setRotateY] = (0, import_react7.useState)(0);
|
|
263
|
+
const [currentScale, setCurrentScale] = (0, import_react7.useState)(1);
|
|
250
264
|
const [glarePos, setGlarePos] = (0, import_react7.useState)({ x: 50, y: 50, opacity: 0 });
|
|
251
265
|
const handleMouseMove = (e) => {
|
|
252
266
|
if (!cardRef.current) return;
|
|
@@ -259,23 +273,25 @@ function TiltCard({
|
|
|
259
273
|
const rotY = (x - centerX) / centerX * maxTilt;
|
|
260
274
|
setRotateX(rotX);
|
|
261
275
|
setRotateY(rotY);
|
|
276
|
+
setCurrentScale(scale);
|
|
262
277
|
if (glare) {
|
|
263
278
|
setGlarePos({
|
|
264
279
|
x: x / rect.width * 100,
|
|
265
280
|
y: y / rect.height * 100,
|
|
266
|
-
opacity:
|
|
281
|
+
opacity: glareOpacity
|
|
267
282
|
});
|
|
268
283
|
}
|
|
269
284
|
};
|
|
270
285
|
const handleMouseLeave = () => {
|
|
271
286
|
setRotateX(0);
|
|
272
287
|
setRotateY(0);
|
|
288
|
+
setCurrentScale(1);
|
|
273
289
|
setGlarePos((prev) => ({ ...prev, opacity: 0 }));
|
|
274
290
|
};
|
|
275
291
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
276
292
|
"div",
|
|
277
293
|
{
|
|
278
|
-
style: { perspective:
|
|
294
|
+
style: { perspective: `${perspective}px` },
|
|
279
295
|
className: "inline-block w-full",
|
|
280
296
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
281
297
|
"div",
|
|
@@ -284,26 +300,26 @@ function TiltCard({
|
|
|
284
300
|
onMouseMove: handleMouseMove,
|
|
285
301
|
onMouseLeave: handleMouseLeave,
|
|
286
302
|
style: {
|
|
287
|
-
transform: `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`,
|
|
288
|
-
transition:
|
|
303
|
+
transform: `rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale3d(${currentScale}, ${currentScale}, ${currentScale})`,
|
|
304
|
+
transition: `transform ${speed}ms cubic-bezier(0.03, 0.98, 0.52, 0.99)`,
|
|
289
305
|
transformStyle: "preserve-3d"
|
|
290
306
|
},
|
|
291
307
|
className: [
|
|
292
|
-
"relative overflow-hidden rounded-3xl border border-white/10 bg-slate-900/80 p-6 backdrop-blur-
|
|
308
|
+
"relative overflow-hidden rounded-3xl border border-white/10 bg-slate-900/80 p-6 shadow-2xl backdrop-blur-md",
|
|
293
309
|
className
|
|
294
310
|
].join(" "),
|
|
295
311
|
children: [
|
|
296
312
|
glare && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
297
313
|
"div",
|
|
298
314
|
{
|
|
299
|
-
className: "pointer-events-none absolute
|
|
315
|
+
className: "pointer-events-none absolute inset-0 transition-opacity duration-300",
|
|
300
316
|
style: {
|
|
301
317
|
opacity: glarePos.opacity,
|
|
302
|
-
background: `radial-gradient(circle at ${glarePos.x}% ${glarePos.y}%,
|
|
318
|
+
background: `radial-gradient(circle at ${glarePos.x}% ${glarePos.y}%, ${glareColor}, transparent 60%)`
|
|
303
319
|
}
|
|
304
320
|
}
|
|
305
321
|
),
|
|
306
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { transform: "translateZ(
|
|
322
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { transform: "translateZ(30px)" }, children })
|
|
307
323
|
]
|
|
308
324
|
}
|
|
309
325
|
)
|
package/dist/index.js
CHANGED
|
@@ -28,15 +28,23 @@ function FadeInSection({
|
|
|
28
28
|
import { motion as motion2, useMotionValue, useSpring } from "motion/react";
|
|
29
29
|
import { useRef } from "react";
|
|
30
30
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
31
|
-
function Magnetic({
|
|
31
|
+
function Magnetic({
|
|
32
|
+
children,
|
|
33
|
+
strength = 0.35,
|
|
34
|
+
damping = 15,
|
|
35
|
+
stiffness = 150,
|
|
36
|
+
mass = 0.1,
|
|
37
|
+
disabled = false,
|
|
38
|
+
className = ""
|
|
39
|
+
}) {
|
|
32
40
|
const ref = useRef(null);
|
|
33
41
|
const x = useMotionValue(0);
|
|
34
42
|
const y = useMotionValue(0);
|
|
35
|
-
const springConfig = { damping
|
|
43
|
+
const springConfig = { damping, stiffness, mass };
|
|
36
44
|
const springX = useSpring(x, springConfig);
|
|
37
45
|
const springY = useSpring(y, springConfig);
|
|
38
46
|
const handleMouseMove = (e) => {
|
|
39
|
-
if (!ref.current) return;
|
|
47
|
+
if (disabled || !ref.current) return;
|
|
40
48
|
const { clientX, clientY } = e;
|
|
41
49
|
const { left, top, width, height } = ref.current.getBoundingClientRect();
|
|
42
50
|
const middleX = clientX - (left + width / 2);
|
|
@@ -55,7 +63,7 @@ function Magnetic({ children, strength = 0.35, className = "" }) {
|
|
|
55
63
|
onMouseMove: handleMouseMove,
|
|
56
64
|
onMouseLeave: handleMouseLeave,
|
|
57
65
|
style: { x: springX, y: springY },
|
|
58
|
-
className: ["inline-block
|
|
66
|
+
className: ["inline-block", className].join(" "),
|
|
59
67
|
children
|
|
60
68
|
}
|
|
61
69
|
);
|
|
@@ -210,12 +218,18 @@ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
|
210
218
|
function TiltCard({
|
|
211
219
|
children,
|
|
212
220
|
maxTilt = 15,
|
|
221
|
+
perspective = 1e3,
|
|
222
|
+
scale = 1.02,
|
|
213
223
|
glare = true,
|
|
224
|
+
glareOpacity = 0.25,
|
|
225
|
+
glareColor = "rgba(255, 255, 255, 0.4)",
|
|
226
|
+
speed = 300,
|
|
214
227
|
className = ""
|
|
215
228
|
}) {
|
|
216
229
|
const cardRef = useRef3(null);
|
|
217
230
|
const [rotateX, setRotateX] = useState2(0);
|
|
218
231
|
const [rotateY, setRotateY] = useState2(0);
|
|
232
|
+
const [currentScale, setCurrentScale] = useState2(1);
|
|
219
233
|
const [glarePos, setGlarePos] = useState2({ x: 50, y: 50, opacity: 0 });
|
|
220
234
|
const handleMouseMove = (e) => {
|
|
221
235
|
if (!cardRef.current) return;
|
|
@@ -228,23 +242,25 @@ function TiltCard({
|
|
|
228
242
|
const rotY = (x - centerX) / centerX * maxTilt;
|
|
229
243
|
setRotateX(rotX);
|
|
230
244
|
setRotateY(rotY);
|
|
245
|
+
setCurrentScale(scale);
|
|
231
246
|
if (glare) {
|
|
232
247
|
setGlarePos({
|
|
233
248
|
x: x / rect.width * 100,
|
|
234
249
|
y: y / rect.height * 100,
|
|
235
|
-
opacity:
|
|
250
|
+
opacity: glareOpacity
|
|
236
251
|
});
|
|
237
252
|
}
|
|
238
253
|
};
|
|
239
254
|
const handleMouseLeave = () => {
|
|
240
255
|
setRotateX(0);
|
|
241
256
|
setRotateY(0);
|
|
257
|
+
setCurrentScale(1);
|
|
242
258
|
setGlarePos((prev) => ({ ...prev, opacity: 0 }));
|
|
243
259
|
};
|
|
244
260
|
return /* @__PURE__ */ jsx6(
|
|
245
261
|
"div",
|
|
246
262
|
{
|
|
247
|
-
style: { perspective:
|
|
263
|
+
style: { perspective: `${perspective}px` },
|
|
248
264
|
className: "inline-block w-full",
|
|
249
265
|
children: /* @__PURE__ */ jsxs4(
|
|
250
266
|
"div",
|
|
@@ -253,26 +269,26 @@ function TiltCard({
|
|
|
253
269
|
onMouseMove: handleMouseMove,
|
|
254
270
|
onMouseLeave: handleMouseLeave,
|
|
255
271
|
style: {
|
|
256
|
-
transform: `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`,
|
|
257
|
-
transition:
|
|
272
|
+
transform: `rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale3d(${currentScale}, ${currentScale}, ${currentScale})`,
|
|
273
|
+
transition: `transform ${speed}ms cubic-bezier(0.03, 0.98, 0.52, 0.99)`,
|
|
258
274
|
transformStyle: "preserve-3d"
|
|
259
275
|
},
|
|
260
276
|
className: [
|
|
261
|
-
"relative overflow-hidden rounded-3xl border border-white/10 bg-slate-900/80 p-6 backdrop-blur-
|
|
277
|
+
"relative overflow-hidden rounded-3xl border border-white/10 bg-slate-900/80 p-6 shadow-2xl backdrop-blur-md",
|
|
262
278
|
className
|
|
263
279
|
].join(" "),
|
|
264
280
|
children: [
|
|
265
281
|
glare && /* @__PURE__ */ jsx6(
|
|
266
282
|
"div",
|
|
267
283
|
{
|
|
268
|
-
className: "pointer-events-none absolute
|
|
284
|
+
className: "pointer-events-none absolute inset-0 transition-opacity duration-300",
|
|
269
285
|
style: {
|
|
270
286
|
opacity: glarePos.opacity,
|
|
271
|
-
background: `radial-gradient(circle at ${glarePos.x}% ${glarePos.y}%,
|
|
287
|
+
background: `radial-gradient(circle at ${glarePos.x}% ${glarePos.y}%, ${glareColor}, transparent 60%)`
|
|
272
288
|
}
|
|
273
289
|
}
|
|
274
290
|
),
|
|
275
|
-
/* @__PURE__ */ jsx6("div", { style: { transform: "translateZ(
|
|
291
|
+
/* @__PURE__ */ jsx6("div", { style: { transform: "translateZ(30px)" }, children })
|
|
276
292
|
]
|
|
277
293
|
}
|
|
278
294
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackvibe-studio/motion",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Motion primitives for StackVibe UI.",
|
|
6
6
|
"repository": {
|
|
@@ -12,6 +12,24 @@
|
|
|
12
12
|
"url": "https://github.com/StackVibe-Studio/stackvibe-ui/issues"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"react",
|
|
17
|
+
"react-19",
|
|
18
|
+
"motion",
|
|
19
|
+
"framer-motion",
|
|
20
|
+
"spring-physics",
|
|
21
|
+
"magnetic",
|
|
22
|
+
"tilt",
|
|
23
|
+
"3d-tilt",
|
|
24
|
+
"ticker",
|
|
25
|
+
"number-ticker",
|
|
26
|
+
"marquee",
|
|
27
|
+
"spotlight",
|
|
28
|
+
"text-reveal",
|
|
29
|
+
"animation",
|
|
30
|
+
"micro-interactions",
|
|
31
|
+
"stackvibe"
|
|
32
|
+
],
|
|
15
33
|
"main": "./dist/index.js",
|
|
16
34
|
"types": "./dist/index.d.ts",
|
|
17
35
|
"exports": {
|