react-3d-carousel-fullcontrol 1.0.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 ADDED
@@ -0,0 +1,70 @@
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13
+
14
+ The page will reload when you make changes.\
15
+ You may also see any lint errors in the console.
16
+
17
+ ### `npm test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `npm run build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `npm run eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35
+
36
+ If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39
+
40
+ You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
47
+
48
+ ### Code Splitting
49
+
50
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51
+
52
+ ### Analyzing the Bundle Size
53
+
54
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55
+
56
+ ### Making a Progressive Web App
57
+
58
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59
+
60
+ ### Advanced Configuration
61
+
62
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63
+
64
+ ### Deployment
65
+
66
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67
+
68
+ ### `npm run build` fails to minify
69
+
70
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "react-3d-carousel-fullcontrol",
3
+ "version": "1.0.0",
4
+ "description": "A highly customizable 3D carousel component for React with full axis rotation control",
5
+ "main": "src/Carousel.jsx",
6
+ "keywords": [
7
+ "react",
8
+ "carousel",
9
+ "3d",
10
+ "slider",
11
+ "gallery",
12
+ "rotation",
13
+ "framer-motion"
14
+ ],
15
+ "author": "Darshan Nandagavi",
16
+ "license": "MIT",
17
+ "peerDependencies": {
18
+ "react": ">=16.8.0",
19
+ "react-dom": ">=16.8.0",
20
+ "framer-motion": ">=6.0.0"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/darshanandagavi/react-3d-carousel"
25
+ }
26
+ }
Binary file
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
package/src/App.css ADDED
@@ -0,0 +1,38 @@
1
+ .App {
2
+ text-align: center;
3
+ }
4
+
5
+ .App-logo {
6
+ height: 40vmin;
7
+ pointer-events: none;
8
+ }
9
+
10
+ @media (prefers-reduced-motion: no-preference) {
11
+ .App-logo {
12
+ animation: App-logo-spin infinite 20s linear;
13
+ }
14
+ }
15
+
16
+ .App-header {
17
+ background-color: #282c34;
18
+ min-height: 100vh;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ justify-content: center;
23
+ font-size: calc(10px + 2vmin);
24
+ color: white;
25
+ }
26
+
27
+ .App-link {
28
+ color: #61dafb;
29
+ }
30
+
31
+ @keyframes App-logo-spin {
32
+ from {
33
+ transform: rotate(0deg);
34
+ }
35
+ to {
36
+ transform: rotate(360deg);
37
+ }
38
+ }
package/src/App.js ADDED
@@ -0,0 +1,25 @@
1
+ import logo from './logo.svg';
2
+ import './App.css';
3
+
4
+ function App() {
5
+ return (
6
+ <div className="App">
7
+ <header className="App-header">
8
+ <img src={logo} className="App-logo" alt="logo" />
9
+ <p>
10
+ Edit <code>src/App.js</code> and save to reload.
11
+ </p>
12
+ <a
13
+ className="App-link"
14
+ href="https://reactjs.org"
15
+ target="_blank"
16
+ rel="noopener noreferrer"
17
+ >
18
+ Learn React
19
+ </a>
20
+ </header>
21
+ </div>
22
+ );
23
+ }
24
+
25
+ export default App;
@@ -0,0 +1,8 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import App from './App';
3
+
4
+ test('renders learn react link', () => {
5
+ render(<App />);
6
+ const linkElement = screen.getByText(/learn react/i);
7
+ expect(linkElement).toBeInTheDocument();
8
+ });
@@ -0,0 +1,671 @@
1
+ import { useEffect, useRef, useState, useCallback, memo } from "react";
2
+ import { motion } from "framer-motion";
3
+
4
+ // ─── Particle system ────────────────────────────────────────────────────────
5
+ function Particles() {
6
+ const count = 80;
7
+ const particles = useRef(
8
+ Array.from({ length: count }, (_, i) => ({
9
+ id: i,
10
+ x: Math.random() * 100,
11
+ y: Math.random() * 100,
12
+ size: Math.random() * 2.5 + 0.5,
13
+ opacity: Math.random() * 0.5 + 0.1,
14
+ dur: Math.random() * 12 + 8,
15
+ delay: Math.random() * -20,
16
+ }))
17
+ ).current;
18
+
19
+ return (
20
+ <div
21
+ style={{
22
+ position: "absolute",
23
+ inset: 0,
24
+ overflow: "hidden",
25
+ pointerEvents: "none",
26
+ zIndex: 1,
27
+ }}
28
+ >
29
+ {particles.map((p) => (
30
+ <motion.div
31
+ key={p.id}
32
+ style={{
33
+ position: "absolute",
34
+ left: `${p.x}%`,
35
+ top: `${p.y}%`,
36
+ width: p.size,
37
+ height: p.size,
38
+ borderRadius: "50%",
39
+ background: `rgba(180,160,255,${p.opacity})`,
40
+ }}
41
+ animate={{
42
+ y: [0, -30, 0],
43
+ opacity: [p.opacity, p.opacity * 2, p.opacity],
44
+ }}
45
+ transition={{
46
+ duration: p.dur,
47
+ repeat: Infinity,
48
+ ease: "easeInOut",
49
+ delay: p.delay,
50
+ }}
51
+ />
52
+ ))}
53
+ </div>
54
+ );
55
+ }
56
+
57
+ // ─── Light blobs ────────────────────────────────────────────────────────────
58
+
59
+ function LightBlobs({ mouseX, mouseY }) {
60
+ return (
61
+ <div
62
+ style={{
63
+ position: "absolute",
64
+ inset: 0,
65
+ pointerEvents: "none",
66
+ zIndex: 0,
67
+ overflow: "hidden",
68
+ }}
69
+ >
70
+ <div
71
+ style={{
72
+ position: "absolute",
73
+ width: 700,
74
+ height: 700,
75
+ borderRadius: "50%",
76
+ left: mouseX - 350,
77
+ top: mouseY - 350,
78
+ background:
79
+ "radial-gradient(circle, rgba(100,80,200,0.12) 0%, transparent 70%)",
80
+ transition: "left 0.6s ease, top 0.6s ease",
81
+ pointerEvents: "none",
82
+ }}
83
+ />
84
+ <motion.div
85
+ style={{
86
+ position: "absolute",
87
+ width: 600,
88
+ height: 600,
89
+ borderRadius: "50%",
90
+ top: "-10%",
91
+ left: "10%",
92
+ background:
93
+ "radial-gradient(circle, rgba(80,40,180,0.18) 0%, transparent 70%)",
94
+ filter: "blur(60px)",
95
+ }}
96
+ animate={{ scale: [1, 1.15, 1], x: [0, 40, 0] }}
97
+ transition={{ duration: 18, repeat: Infinity, ease: "easeInOut" }}
98
+ />
99
+ <motion.div
100
+ style={{
101
+ position: "absolute",
102
+ width: 500,
103
+ height: 500,
104
+ borderRadius: "50%",
105
+ bottom: "-5%",
106
+ right: "5%",
107
+ background:
108
+ "radial-gradient(circle, rgba(40,100,200,0.14) 0%, transparent 70%)",
109
+ filter: "blur(80px)",
110
+ }}
111
+ animate={{ scale: [1, 1.2, 1], y: [0, -50, 0] }}
112
+ transition={{ duration: 14, repeat: Infinity, ease: "easeInOut", delay: 3 }}
113
+ />
114
+ <motion.div
115
+ style={{
116
+ position: "absolute",
117
+ width: 400,
118
+ height: 400,
119
+ borderRadius: "50%",
120
+ top: "40%",
121
+ left: "40%",
122
+ background:
123
+ "radial-gradient(circle, rgba(160,60,220,0.08) 0%, transparent 70%)",
124
+ filter: "blur(100px)",
125
+ }}
126
+ animate={{ scale: [1, 1.3, 1] }}
127
+ transition={{ duration: 22, repeat: Infinity, ease: "easeInOut", delay: 7 }}
128
+ />
129
+ </div>
130
+ );
131
+ }
132
+
133
+ // ─── Single carousel card ────────────────────────────────────────────────────
134
+
135
+ const CarouselCard = memo(function CarouselCard({
136
+ image,
137
+ index,
138
+ totalAngle,
139
+ opacity,
140
+ angleStep,
141
+ radius,
142
+ cardWidth,
143
+ cardHeight,
144
+ }) {
145
+ const angle = index * angleStep;
146
+ const [hovered, setHovered] = useState(false);
147
+
148
+ const normalizedAngle = ((totalAngle + angle) % 360 + 360) % 360;
149
+ const frontness = Math.max(0, Math.cos((normalizedAngle * Math.PI) / 180));
150
+
151
+ return (
152
+ <div
153
+ style={{
154
+ position: "absolute",
155
+ width: `${cardWidth}px`,
156
+ height: `${cardHeight}px`,
157
+ left: `-${cardWidth / 2}px`,
158
+ top: `-${cardHeight / 2}px`,
159
+ transform: `rotateY(${angle}deg) translateZ(${radius}px)`,
160
+ transformStyle: "preserve-3d",
161
+ backfaceVisibility: "visible",
162
+ WebkitBackfaceVisibility: "visible",
163
+ opacity: opacity || 1,
164
+ willChange: "transform, opacity",
165
+ }}
166
+ >
167
+ <motion.div
168
+ onHoverStart={() => setHovered(true)}
169
+ onHoverEnd={() => setHovered(false)}
170
+ animate={{
171
+ y: hovered ? -12 : 0,
172
+ }}
173
+ transition={{ type: "spring", stiffness: 300, damping: 22 }}
174
+ style={{
175
+ width: "100%",
176
+ height: "100%",
177
+ borderRadius: "12px",
178
+ overflow: "hidden",
179
+ position: "relative",
180
+ cursor: "pointer",
181
+ willChange: "transform",
182
+ boxShadow: hovered
183
+ ? `0 20px 40px rgba(0,0,0,0.8)`
184
+ : `0 10px 20px rgba(0,0,0,0.5)`,
185
+ transition: "box-shadow 0.4s ease",
186
+ }}
187
+ >
188
+ <img
189
+ src={image.src}
190
+ alt={image.label || `Card ${index + 1}`}
191
+ loading="lazy"
192
+ style={{
193
+ width: "100%",
194
+ height: "100%",
195
+ objectFit: "cover",
196
+ display: "block",
197
+ borderRadius: "12px",
198
+ filter: hovered
199
+ ? "brightness(1.2) saturate(1.3) contrast(1.1)"
200
+ : `brightness(${0.65 + frontness * 0.3}) saturate(1.05)`,
201
+ transition: "filter 0.4s ease",
202
+ }}
203
+ />
204
+
205
+ <div
206
+ style={{
207
+ position: "absolute",
208
+ inset: 0,
209
+ background:
210
+ "linear-gradient(180deg, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.55) 100%)",
211
+ zIndex: 2,
212
+ }}
213
+ />
214
+
215
+ {image.label && (
216
+ <div
217
+ style={{
218
+ position: "absolute",
219
+ bottom: 0,
220
+ left: 0,
221
+ right: 0,
222
+ padding: "20px 16px 16px",
223
+ zIndex: 4,
224
+ background:
225
+ "linear-gradient(0deg, rgba(0,0,0,0.7) 0%, transparent 100%)",
226
+ }}
227
+ >
228
+ <div
229
+ style={{
230
+ fontFamily: "'SF Pro Display', 'Helvetica Neue', sans-serif",
231
+ fontSize: "13px",
232
+ fontWeight: 600,
233
+ color: "rgba(255,255,255,0.9)",
234
+ letterSpacing: "0.08em",
235
+ textTransform: "uppercase",
236
+ }}
237
+ >
238
+ {image.label}
239
+ </div>
240
+ </div>
241
+ )}
242
+
243
+ <motion.div
244
+ animate={hovered ? { opacity: [0, 0.15, 0], x: ["-100%", "200%"] } : { opacity: 0 }}
245
+ transition={{ duration: 0.7, ease: "easeInOut" }}
246
+ style={{
247
+ position: "absolute",
248
+ inset: 0,
249
+ background:
250
+ "linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.4) 50%, transparent 60%)",
251
+ zIndex: 5,
252
+ }}
253
+ />
254
+ </motion.div>
255
+
256
+ <div
257
+ style={{
258
+ position: "absolute",
259
+ top: "105%",
260
+ left: "5%",
261
+ right: "5%",
262
+ height: "80px",
263
+ background: `url(${image.src}) center/cover no-repeat`,
264
+ borderRadius: "12px",
265
+ transform: "scaleY(-1)",
266
+ opacity: 0.12 + frontness * 0.08,
267
+ maskImage: "linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%)",
268
+ WebkitMaskImage: "linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%)",
269
+ filter: "blur(3px)",
270
+ pointerEvents: "none",
271
+ }}
272
+ />
273
+ </div>
274
+ );
275
+ });
276
+
277
+ // ─── Main reusable carousel component ────────────────────────────────────────
278
+
279
+ /**
280
+ * 3D Carousel with full axis rotation control and auto-rotation
281
+ *
282
+ * @param {Object} props
283
+ * @param {Array<{src: string, label?: string}>} props.images
284
+ * @param {Object} [props.defaultRotation] - Default rotation { x: -20, y: 10, z: 20 }
285
+ * @param {boolean} [props.controlled=false] - Return to default position on release
286
+ * @param {function} [props.onRotationChange] - Callback with current rotation
287
+ * @param {number} [props.autoRotateSpeed=0.3] - Auto rotation speed for Y axis (degrees per frame)
288
+ * @param {Object} [props.autoRotateAxes] - Which axes to auto-rotate { x: false, y: true, z: false }
289
+ * @param {boolean} [props.pauseOnDrag=true] - Pause auto-rotation while dragging
290
+ * @param {number} [props.cardWidth=220]
291
+ * @param {number} [props.cardHeight=300]
292
+ * @param {number} [props.gap=2]
293
+ * @param {number} [props.perspective=2000]
294
+ * @param {number} [props.sensitivity=0.4] - Mouse drag sensitivity
295
+ * @param {boolean} [props.showDragHint=true]
296
+ * @param {string} [props.className=""]
297
+ * @param {Object} [props.style={}]
298
+ */
299
+ function Carousel({
300
+ images = [],
301
+ defaultRotation = { x: -20, y: 10, z: 20 },
302
+ controlled = false,
303
+ onRotationChange,
304
+ autoRotateSpeed = 0.3,
305
+ autoRotateAxes = { x: false, y: true, z: false },
306
+ pauseOnDrag = true,
307
+ cardWidth = 220,
308
+ cardHeight = 300,
309
+ gap = 2,
310
+ perspective = 2000,
311
+ sensitivity = 0.4,
312
+ showDragHint = true,
313
+ className = "",
314
+ style = {},
315
+ }) {
316
+ const rotationRef = useRef({
317
+ x: defaultRotation.x ?? -20,
318
+ y: defaultRotation.y ?? 10,
319
+ z: defaultRotation.z ?? 20,
320
+ });
321
+
322
+ const rafRef = useRef(null);
323
+ const isDragging = useRef(false);
324
+ const lastMousePos = useRef({ x: 0, y: 0 });
325
+ const velocityRef = useRef({ x: 0, y: 0, z: 0 });
326
+ const [renderRotation, setRenderRotation] = useState({ ...rotationRef.current });
327
+ const returnAnimRef = useRef(null);
328
+
329
+ const cardCount = images.length;
330
+ const angleStep = cardCount > 0 ? 360 / cardCount : 0;
331
+ const radius = cardCount > 0 ? ((cardWidth + gap) * cardCount) / (2 * Math.PI) : 0;
332
+
333
+ // Sync with defaultRotation prop changes
334
+ useEffect(() => {
335
+ if (!isDragging.current) {
336
+ rotationRef.current = {
337
+ x: defaultRotation.x ?? -20,
338
+ y: defaultRotation.y ?? 10,
339
+ z: defaultRotation.z ?? 20,
340
+ };
341
+ setRenderRotation({ ...rotationRef.current });
342
+ }
343
+ }, [defaultRotation.x, defaultRotation.y, defaultRotation.z]);
344
+
345
+ // Animation loop
346
+ useEffect(() => {
347
+ if (cardCount === 0) return;
348
+
349
+ let lastTime = performance.now();
350
+
351
+ const tick = (now) => {
352
+ const delta = Math.min(now - lastTime, 32);
353
+ lastTime = now;
354
+
355
+ const isCurrentlyDragging = isDragging.current;
356
+
357
+ if (!isCurrentlyDragging) {
358
+ // Apply friction to all velocities
359
+ velocityRef.current.x *= 0.94;
360
+ velocityRef.current.y *= 0.94;
361
+ velocityRef.current.z *= 0.94;
362
+
363
+ if (Math.abs(velocityRef.current.x) < 0.001) velocityRef.current.x = 0;
364
+ if (Math.abs(velocityRef.current.y) < 0.001) velocityRef.current.y = 0;
365
+ if (Math.abs(velocityRef.current.z) < 0.001) velocityRef.current.z = 0;
366
+
367
+ if (!controlled) {
368
+ // Free mode: apply auto-rotation to all specified axes
369
+ if (autoRotateAxes.x) rotationRef.current.x += autoRotateSpeed * (delta / 16.67);
370
+ if (autoRotateAxes.y) rotationRef.current.y += autoRotateSpeed * (delta / 16.67);
371
+ if (autoRotateAxes.z) rotationRef.current.z += autoRotateSpeed * (delta / 16.67);
372
+
373
+ // Add momentum
374
+ rotationRef.current.x += velocityRef.current.x;
375
+ rotationRef.current.y += velocityRef.current.y;
376
+ rotationRef.current.z += velocityRef.current.z;
377
+ } else {
378
+ // Controlled mode: apply momentum and return to default
379
+ rotationRef.current.x += velocityRef.current.x;
380
+ rotationRef.current.y += velocityRef.current.y;
381
+ rotationRef.current.z += velocityRef.current.z;
382
+
383
+ // If velocities are near zero, return to default position
384
+ if (Math.abs(velocityRef.current.x) < 0.01 &&
385
+ Math.abs(velocityRef.current.y) < 0.01 &&
386
+ Math.abs(velocityRef.current.z) < 0.01) {
387
+
388
+ const returnSpeed = 0.08;
389
+ const targetX = defaultRotation.x ?? -20;
390
+ const targetY = defaultRotation.y ?? 10;
391
+ const targetZ = defaultRotation.z ?? 20;
392
+
393
+ rotationRef.current.x += (targetX - rotationRef.current.x) * returnSpeed;
394
+ rotationRef.current.y += (targetY - rotationRef.current.y) * returnSpeed;
395
+ rotationRef.current.z += (targetZ - rotationRef.current.z) * returnSpeed;
396
+ }
397
+ }
398
+ } else if (pauseOnDrag) {
399
+ // During drag: only apply auto-rotation if pauseOnDrag is false
400
+ // (Currently paused, but momentum is handled in pointer move)
401
+ }
402
+
403
+ setRenderRotation({ ...rotationRef.current });
404
+
405
+ if (onRotationChange) {
406
+ onRotationChange({ ...rotationRef.current });
407
+ }
408
+
409
+ rafRef.current = requestAnimationFrame(tick);
410
+ };
411
+
412
+ rafRef.current = requestAnimationFrame(tick);
413
+ return () => {
414
+ if (rafRef.current) cancelAnimationFrame(rafRef.current);
415
+ if (returnAnimRef.current) cancelAnimationFrame(returnAnimRef.current);
416
+ };
417
+ }, [controlled, defaultRotation, autoRotateSpeed, autoRotateAxes, pauseOnDrag, onRotationChange, cardCount]);
418
+
419
+ // Interaction handlers
420
+ const handlePointerDown = useCallback((clientX, clientY) => {
421
+ isDragging.current = true;
422
+ lastMousePos.current = { x: clientX, y: clientY };
423
+ velocityRef.current = { x: 0, y: 0, z: 0 };
424
+
425
+ if (returnAnimRef.current) {
426
+ cancelAnimationFrame(returnAnimRef.current);
427
+ returnAnimRef.current = null;
428
+ }
429
+ }, []);
430
+
431
+ const handlePointerMove = useCallback((clientX, clientY) => {
432
+ if (!isDragging.current) return;
433
+
434
+ const dx = clientX - lastMousePos.current.x;
435
+ const dy = clientY - lastMousePos.current.y;
436
+
437
+ // Horizontal drag = Y axis rotation (spin around)
438
+ rotationRef.current.y += dx * sensitivity;
439
+
440
+ // Vertical drag = X axis rotation (tilt forward/backward)
441
+ rotationRef.current.x -= dy * sensitivity * 0.6;
442
+
443
+ // Diagonal drag = Z axis rotation (roll/twist)
444
+ if (Math.abs(dx) > 2 && Math.abs(dy) > 2) {
445
+ const diagonalComponent = (dx * dy) / Math.sqrt(dx * dx + dy * dy);
446
+ rotationRef.current.z += diagonalComponent * sensitivity * 0.3;
447
+ }
448
+
449
+ // Store velocities for momentum
450
+ velocityRef.current.y = dx * sensitivity * 0.5;
451
+ velocityRef.current.x = -dy * sensitivity * 0.3;
452
+ velocityRef.current.z = (dx * dy / Math.sqrt(dx * dx + dy * dy || 1)) * sensitivity * 0.2;
453
+
454
+ // Clamp rotations to reasonable ranges
455
+ rotationRef.current.x = Math.max(-75, Math.min(75, rotationRef.current.x));
456
+ rotationRef.current.z = Math.max(-45, Math.min(45, rotationRef.current.z));
457
+
458
+ lastMousePos.current = { x: clientX, y: clientY };
459
+ }, [sensitivity]);
460
+
461
+ const handlePointerUp = useCallback(() => {
462
+ isDragging.current = false;
463
+ }, []);
464
+
465
+ // Mouse events
466
+ const onMouseDown = useCallback((e) => {
467
+ e.preventDefault();
468
+ handlePointerDown(e.clientX, e.clientY);
469
+ }, [handlePointerDown]);
470
+
471
+ const onMouseMove = useCallback((e) => {
472
+ handlePointerMove(e.clientX, e.clientY);
473
+ }, [handlePointerMove]);
474
+
475
+ const onMouseUp = useCallback(() => {
476
+ handlePointerUp();
477
+ }, [handlePointerUp]);
478
+
479
+ // Touch events
480
+ const onTouchStart = useCallback((e) => {
481
+ handlePointerDown(e.touches[0].clientX, e.touches[0].clientY);
482
+ }, [handlePointerDown]);
483
+
484
+ const onTouchMove = useCallback((e) => {
485
+ handlePointerMove(e.touches[0].clientX, e.touches[0].clientY);
486
+ }, [handlePointerMove]);
487
+
488
+ const onTouchEnd = useCallback(() => {
489
+ handlePointerUp();
490
+ }, [handlePointerUp]);
491
+
492
+ // Empty state
493
+ if (cardCount === 0) {
494
+ return (
495
+ <div className={className} style={{ position: "relative", width: "100%", height: "100%", ...style }}>
496
+ <div style={{
497
+ position: "absolute",
498
+ top: "50%",
499
+ left: "50%",
500
+ transform: "translate(-50%, -50%)",
501
+ color: "rgba(255,255,255,0.5)",
502
+ fontSize: "16px"
503
+ }}>
504
+ No images to display
505
+ </div>
506
+ </div>
507
+ );
508
+ }
509
+
510
+ // Sort cards by depth for proper rendering
511
+ const sortedImages = [...images].map((image, i) => {
512
+ const angle = i * angleStep;
513
+ const totalAngle = (renderRotation.y + angle) % 360;
514
+ const zDepth = Math.cos((totalAngle * Math.PI) / 180);
515
+ return { image, index: i, zDepth };
516
+ }).sort((a, b) => a.zDepth - b.zDepth);
517
+
518
+ return (
519
+ <div
520
+ className={className}
521
+ style={{
522
+ position: "relative",
523
+ width: "100%",
524
+ height: "100%",
525
+ perspective: `${perspective}px`,
526
+ perspectiveOrigin: "50% 50%",
527
+ cursor: isDragging.current ? "grabbing" : "grab",
528
+ userSelect: "none",
529
+ touchAction: "none",
530
+ ...style,
531
+ }}
532
+ onMouseDown={onMouseDown}
533
+ onMouseMove={onMouseMove}
534
+ onMouseUp={onMouseUp}
535
+ onMouseLeave={onMouseUp}
536
+ onTouchStart={onTouchStart}
537
+ onTouchMove={onTouchMove}
538
+ onTouchEnd={onTouchEnd}
539
+ >
540
+ {/* Apply all 3 axis rotations */}
541
+ <div
542
+ style={{
543
+ position: "absolute",
544
+ top: "50%",
545
+ left: "50%",
546
+ transformStyle: "preserve-3d",
547
+ transform: `translate(-50%, -50%) rotateX(${renderRotation.x}deg) rotateY(${renderRotation.y}deg) rotateZ(${renderRotation.z}deg)`,
548
+ willChange: "transform",
549
+ }}
550
+ >
551
+ {sortedImages.map(({ image, index, zDepth }) => (
552
+ <CarouselCard
553
+ key={index}
554
+ image={image}
555
+ index={index}
556
+ totalAngle={renderRotation.y}
557
+ opacity={0.3 + (zDepth + 1) * 0.35}
558
+ angleStep={angleStep}
559
+ radius={radius}
560
+ cardWidth={cardWidth}
561
+ cardHeight={cardHeight}
562
+ />
563
+ ))}
564
+ </div>
565
+
566
+ {showDragHint && (
567
+ <motion.div
568
+ initial={{ opacity: 0 }}
569
+ animate={{ opacity: 1 }}
570
+ transition={{ delay: 2.5, duration: 1 }}
571
+ style={{
572
+ position: "absolute",
573
+ bottom: "28px",
574
+ left: "50%",
575
+ transform: "translateX(-50%)",
576
+ zIndex: 10,
577
+ color: "rgba(255,255,255,0.25)",
578
+ fontSize: "11px",
579
+ letterSpacing: "0.2em",
580
+ textTransform: "uppercase",
581
+ textAlign: "center",
582
+ pointerEvents: "none",
583
+ }}
584
+ >
585
+ drag to rotate • auto-rotating
586
+ </motion.div>
587
+ )}
588
+ </div>
589
+ );
590
+ }
591
+
592
+ // ─── Full page component with backgrounds ────────────────────────────────────
593
+
594
+ function CarouselWithBackground({
595
+ images,
596
+ defaultRotation,
597
+ controlled,
598
+ onRotationChange,
599
+ ...carouselProps
600
+ }) {
601
+ const containerRef = useRef(null);
602
+ const [mouse, setMouse] = useState({ x: 0, y: 0 });
603
+
604
+ useEffect(() => {
605
+ const onResize = () => {
606
+ setMouse(prev => ({ ...prev }));
607
+ };
608
+ window.addEventListener("resize", onResize);
609
+ return () => window.removeEventListener("resize", onResize);
610
+ }, []);
611
+
612
+ const onMouseMove = useCallback((e) => {
613
+ setMouse({ x: e.clientX, y: e.clientY });
614
+ }, []);
615
+
616
+ return (
617
+ <div
618
+ ref={containerRef}
619
+ onMouseMove={onMouseMove}
620
+ style={{
621
+ position: "relative",
622
+ width: "100vw",
623
+ height: "100vh",
624
+ background: "#000",
625
+ overflow: "hidden",
626
+ fontFamily: "'SF Pro Display', 'Helvetica Neue', sans-serif",
627
+ }}
628
+ >
629
+ <LightBlobs mouseX={mouse.x} mouseY={mouse.y} />
630
+ <Particles />
631
+
632
+ <div
633
+ style={{
634
+ position: "absolute",
635
+ inset: 0,
636
+ background:
637
+ "radial-gradient(ellipse 60% 40% at 50% 65%, rgba(80,50,160,0.18) 0%, transparent 70%)",
638
+ pointerEvents: "none",
639
+ zIndex: 1,
640
+ }}
641
+ />
642
+
643
+ <div
644
+ style={{
645
+ position: "absolute",
646
+ bottom: 0,
647
+ left: 0,
648
+ right: 0,
649
+ height: "35%",
650
+ background:
651
+ "linear-gradient(to top, rgba(20,10,40,0.5) 0%, transparent 100%)",
652
+ pointerEvents: "none",
653
+ zIndex: 2,
654
+ }}
655
+ />
656
+
657
+ <div style={{ position: "absolute", inset: 0, zIndex: 5 }}>
658
+ <Carousel
659
+ images={images}
660
+ defaultRotation={defaultRotation}
661
+ controlled={controlled}
662
+ onRotationChange={onRotationChange}
663
+ {...carouselProps}
664
+ />
665
+ </div>
666
+ </div>
667
+ );
668
+ }
669
+
670
+ export { Carousel, CarouselWithBackground };
671
+ export default Carousel;
package/src/index.css ADDED
@@ -0,0 +1,13 @@
1
+ body {
2
+ margin: 0;
3
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
+ sans-serif;
6
+ -webkit-font-smoothing: antialiased;
7
+ -moz-osx-font-smoothing: grayscale;
8
+ }
9
+
10
+ code {
11
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12
+ monospace;
13
+ }
package/src/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import './index.css';
4
+ import App from './App';
5
+ import reportWebVitals from './reportWebVitals';
6
+
7
+ const root = ReactDOM.createRoot(document.getElementById('root'));
8
+ root.render(
9
+ <React.StrictMode>
10
+ <App />
11
+ </React.StrictMode>
12
+ );
13
+
14
+ // If you want to start measuring performance in your app, pass a function
15
+ // to log results (for example: reportWebVitals(console.log))
16
+ // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17
+ reportWebVitals();
package/src/logo.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
@@ -0,0 +1,13 @@
1
+ const reportWebVitals = onPerfEntry => {
2
+ if (onPerfEntry && onPerfEntry instanceof Function) {
3
+ import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4
+ getCLS(onPerfEntry);
5
+ getFID(onPerfEntry);
6
+ getFCP(onPerfEntry);
7
+ getLCP(onPerfEntry);
8
+ getTTFB(onPerfEntry);
9
+ });
10
+ }
11
+ };
12
+
13
+ export default reportWebVitals;
@@ -0,0 +1,5 @@
1
+ // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
+ // allows you to do things like:
3
+ // expect(element).toHaveTextContent(/react/i)
4
+ // learn more: https://github.com/testing-library/jest-dom
5
+ import '@testing-library/jest-dom';