react-magic-card 0.0.2 → 0.0.3
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/MagicCircle/index.js +50 -27
- package/package.json +1 -1
- package/readme.md +11 -15
|
@@ -101,32 +101,55 @@ const MagicCircle = ({ data, width, height, radius, controller, start, dynamic,
|
|
|
101
101
|
}, []);
|
|
102
102
|
// angle between images.
|
|
103
103
|
const angle = parseFloat((2 * Math.PI).toFixed(15)) / data.length;
|
|
104
|
-
return (react_1.default.createElement(framer_motion_1.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
104
|
+
return (react_1.default.createElement(framer_motion_1.LazyMotion, { features: framer_motion_1.domAnimation },
|
|
105
|
+
react_1.default.createElement(framer_motion_1.m.div, { ref: ref, className: className + ' ' + 'outer', style: {
|
|
106
|
+
width: radius * 2 + controller + 'px',
|
|
107
|
+
height: radius * 2 + controller + 'px'
|
|
108
|
+
}, animate: { rotate: count }, transition: { duration: transition === null || transition === void 0 ? void 0 : transition.duration } },
|
|
109
|
+
react_1.default.createElement("div", { className: "inner", style: { width: radius * 2 + 'px', height: radius * 2 + 'px' } }, images.map((image, index) => {
|
|
110
|
+
const hasSelect = images[select] == images[index];
|
|
111
|
+
return (react_1.default.createElement(framer_motion_1.m.img, { key: index, animate: {
|
|
112
|
+
scale: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectScale : animate === null || animate === void 0 ? void 0 : animate.scale,
|
|
113
|
+
opacity: hasSelect
|
|
114
|
+
? animate === null || animate === void 0 ? void 0 : animate.selectOpacity
|
|
115
|
+
: animate === null || animate === void 0 ? void 0 : animate.opacity,
|
|
116
|
+
rotateX: hasSelect
|
|
117
|
+
? animate === null || animate === void 0 ? void 0 : animate.selectRotateX
|
|
118
|
+
: animate === null || animate === void 0 ? void 0 : animate.rotateX,
|
|
119
|
+
rotateY: hasSelect
|
|
120
|
+
? animate === null || animate === void 0 ? void 0 : animate.selectRotateY
|
|
121
|
+
: animate === null || animate === void 0 ? void 0 : animate.rotateY,
|
|
122
|
+
rotateZ: hasSelect
|
|
123
|
+
? animate === null || animate === void 0 ? void 0 : animate.selectRotateZ
|
|
124
|
+
: animate === null || animate === void 0 ? void 0 : animate.rotateZ,
|
|
125
|
+
rotate: -count
|
|
126
|
+
}, initial: {
|
|
127
|
+
scale: hasSelect ? initial === null || initial === void 0 ? void 0 : initial.selectScale : initial === null || initial === void 0 ? void 0 : initial.scale,
|
|
128
|
+
opacity: hasSelect
|
|
129
|
+
? initial === null || initial === void 0 ? void 0 : initial.selectOpacity
|
|
130
|
+
: initial === null || initial === void 0 ? void 0 : initial.opacity,
|
|
131
|
+
rotateX: hasSelect
|
|
132
|
+
? initial === null || initial === void 0 ? void 0 : initial.selectRotateX
|
|
133
|
+
: initial === null || initial === void 0 ? void 0 : initial.rotateX,
|
|
134
|
+
rotateY: hasSelect
|
|
135
|
+
? initial === null || initial === void 0 ? void 0 : initial.selectRotateY
|
|
136
|
+
: initial === null || initial === void 0 ? void 0 : initial.rotateY,
|
|
137
|
+
rotateZ: hasSelect
|
|
138
|
+
? initial === null || initial === void 0 ? void 0 : initial.selectRotateZ
|
|
139
|
+
: initial === null || initial === void 0 ? void 0 : initial.rotateZ,
|
|
140
|
+
rotate: -count
|
|
141
|
+
}, transition: transition, onClick: () => setSelect(index), className: classImage + ' ' + classImageUnique + index, src: image.src, alt: image.alt, style: {
|
|
142
|
+
width: width + 'px',
|
|
143
|
+
height: height + 'px',
|
|
144
|
+
left: radius * Math.cos(index * angle) +
|
|
145
|
+
radius -
|
|
146
|
+
width / 2 +
|
|
147
|
+
'px',
|
|
148
|
+
top: radius * Math.sin(index * angle) +
|
|
149
|
+
radius -
|
|
150
|
+
height / 2 +
|
|
151
|
+
'px'
|
|
152
|
+
} }));
|
|
153
|
+
})))));
|
|
131
154
|
};
|
|
132
155
|
exports.MagicCircle = MagicCircle;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -15,23 +15,23 @@ npm install react-magic-card framer-motion
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
|
-
import { MagicCircle } from
|
|
18
|
+
import { MagicCircle } from "react-magic-card";
|
|
19
19
|
|
|
20
20
|
function MyComponent() {
|
|
21
21
|
const images = [
|
|
22
22
|
{
|
|
23
|
-
src:
|
|
24
|
-
alt:
|
|
23
|
+
src: "/1.jpeg",
|
|
24
|
+
alt: "1image",
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
src:
|
|
28
|
-
alt:
|
|
27
|
+
src: "/2.jpeg",
|
|
28
|
+
alt: "2image",
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
|
-
src:
|
|
32
|
-
alt:
|
|
33
|
-
}
|
|
34
|
-
]
|
|
31
|
+
src: "/3.jpeg",
|
|
32
|
+
alt: "3image",
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
37
|
<MagicCircle
|
|
@@ -51,18 +51,14 @@ function MyComponent() {
|
|
|
51
51
|
selectScale: 1.6,
|
|
52
52
|
selectRotateX: 40,
|
|
53
53
|
selectRotateY: 40,
|
|
54
|
-
selectRotateZ: -10
|
|
54
|
+
selectRotateZ: -10,
|
|
55
55
|
}}
|
|
56
56
|
transition={{ duration: 0.2 }}
|
|
57
57
|
/>
|
|
58
|
-
)
|
|
58
|
+
);
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
## use LazyMotion
|
|
63
|
-
|
|
64
|
-
because It is using 「m」 need to wrap it with LazyMotion at the root layout level.
|
|
65
|
-
|
|
66
62
|
## Properties
|
|
67
63
|
|
|
68
64
|
- data: An array a images property objects for src and alt.
|