react-magic-card 1.1.2 → 2.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 CHANGED
@@ -1,10 +1,8 @@
1
- # react-magic-card
2
-
3
1
  [![Release Status](https://img.shields.io/github/release/su-pull/react-magic-card.svg)](https://github.com/su-pull/react-magic-card/releases/latest)
4
2
  [![Minzip Size](https://img.shields.io/bundlephobia/minzip/react-magic-card)](https://bundlephobia.com/package/react-magic-card)
5
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
4
 
7
- This is the framer motion components, that support images gallery.
5
+ This is the framer motion animation components, that support images gallery.
8
6
 
9
7
  ## Installation
10
8
 
@@ -15,27 +13,33 @@ npm install react-magic-card framer-motion
15
13
  ## Usage Guide
16
14
 
17
15
  ```tsx
18
- import { MagicCircle } from 'react-magic-card'
16
+ import { StraightInfinity } from "react-magic-card";
19
17
 
20
18
  function MyComponent() {
21
19
  const images = [
22
20
  {
23
- src: '/src.jpeg',
24
- alt: 'alt'
25
- }
26
- ]
21
+ src: "/cat.jpeg",
22
+ alt: "alt",
23
+ },
24
+ {
25
+ src: "/dog.jpeg",
26
+ alt: "alt",
27
+ },
28
+ {
29
+ src: "/bird.jpeg",
30
+ alt: "alt",
31
+ },
32
+ ];
27
33
 
28
34
  return (
29
- <MagicCircle
35
+ <StraightInfinity
30
36
  images={images}
31
37
  width={100}
32
38
  height={100}
33
- radius={100}
34
39
  controller={100}
35
- start={1}
36
- delay={100}
40
+ start={Math.ceil(images.length / 2)}
37
41
  />
38
- )
42
+ );
39
43
  }
40
44
  ```
41
45
 
@@ -48,12 +52,8 @@ function MyComponent() {
48
52
  | width (required) | width of the single image |
49
53
  | height (required) | height of the single image |
50
54
  | controller (required) | controller size is add to the size of the component |
51
- | delay | delay of the animation firing interval |
52
55
  | offsetIndex | add an offset to the index of the components and images |
53
56
  | reverseIndex | order the change the overlap of zindex default true |
54
- | loading | loading attribute of img element in html |
55
- | initialFadeRange | range of fade animation after page loaded |
56
- | initialTransTime | transition time of fade animation after page loaded |
57
57
  | className | className of the component |
58
58
  | classImages | className of the images |
59
59
  | classImageSelect | className of the select image |
@@ -61,24 +61,24 @@ function MyComponent() {
61
61
  | animate | object in the animation property |
62
62
  | initial | object in the animation property |
63
63
  | transition | object in the transition property |
64
- | pickTransition | object in the transition property |
65
- | pickProperty | object in the pick property |
64
+ | detailTransition | object in the transition property |
65
+ | detailProperty | object in the detail property |
66
+ | loading | loading attribute of img element in html |
67
+ | initialFadeRange | range of fade animation after page loaded |
68
+ | initialTransTime | transition time of fade animation after page loaded |
66
69
 
67
- ## MagicCircle Properties
70
+ ## CircleRotation Properties
68
71
 
69
- | Property | Meaning |
70
- | ----------------- | ----------------------------------------------- |
71
- | radius (required) | radius of the circle |
72
- | dynamic | dynamic or static for rotation the default true |
72
+ | Property | Meaning |
73
+ | ----------------- | -------------------- |
74
+ | radius (required) | radius of the circle |
73
75
 
74
- ## MagicStraight Properties
76
+ ## StraightInfinity Properties
75
77
 
76
- | Property | Meaning |
77
- | ------------- | --------------------------------------- |
78
- | vertical | vertical or horizontal the default true |
79
- | margin | spacing of the between images |
80
- | selectOffsetX | X-axis position |
81
- | selectOffsetY | Y-axis position |
78
+ | Property | Meaning |
79
+ | -------- | --------------------------------------- |
80
+ | vertical | vertical or horizontal the default true |
81
+ | margin | spacing of the between images |
82
82
 
83
83
  ## Animation Object
84
84
 
@@ -99,16 +99,16 @@ function MyComponent() {
99
99
 
100
100
  It is Inherits framer motion transition object other than intera.
101
101
 
102
- ## PickProperty Object
102
+ ## detailProperty Object
103
103
 
104
- | Property | Meaning |
105
- | --------- | --------------------------------------------------------- |
106
- | classPick | className of the pick image |
107
- | white | white or black for background the default true |
108
- | alpha | background transparency of a number between 0 ~ 1 |
109
- | blur | blur intensity of a number between 1 ~ 20 a preferred |
110
- | scale | scale of the pick image |
111
- | offset | offset of an appearance position from the center position |
104
+ | Property | Meaning |
105
+ | ----------- | --------------------------------------------------------- |
106
+ | classDetail | className of the detail image |
107
+ | white | white or black for background the default true |
108
+ | alpha | background transparency of a number between 0 ~ 1 |
109
+ | blur | blur intensity of a number between 1 ~ 20 a preferred |
110
+ | scale | scale of the detail image |
111
+ | offset | offset of an appearance position from the center position |
112
112
 
113
113
  ## License
114
114
 
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { CircleRotationProps } from '../types';
3
+ export declare const CircleRotation: ({ images, start, height, width, radius, controller, offsetIndex, reverseIndex, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, detail, detailProperty, detailTransition, loading, initialFadeRange, initialFadeTime }: CircleRotationProps) => React.JSX.Element;
@@ -26,12 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.MagicCircle = void 0;
29
+ exports.CircleRotation = void 0;
30
30
  const react_1 = __importStar(require("react"));
31
31
  const framer_motion_1 = require("framer-motion");
32
32
  const styles_module_css_1 = __importDefault(require("./styles.module.css"));
33
- const PickImage_1 = __importDefault(require("../common/PickImage"));
34
- const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirection = true, radius, delay = 100, controller, offsetIndex = 0, reverseIndex = true, loading, initialFadeRange = 4, initialTransTime = 0.2, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickScale = true, pickProperty, pickTransition }) => {
33
+ const DetailImage_1 = require("../common/DetailImage");
34
+ const CircleRotation = ({ images, start, height, width, radius, controller, offsetIndex = 0, reverseIndex = true, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, detail = true, detailProperty, detailTransition, loading = 'lazy', initialFadeRange = 1, initialFadeTime = 0.2 }) => {
35
35
  // array out of range adjusting.
36
36
  start = Math.max(0, start);
37
37
  start = Math.min(start, images.length - 1);
@@ -42,38 +42,33 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
42
42
  const [initialY, setInitialY] = (0, react_1.useState)(0);
43
43
  const [isDragging, setIsDragging] = (0, react_1.useState)(false);
44
44
  const [hasMove, setHasMove] = (0, react_1.useState)(false);
45
- const [hasShift, setHasShift] = (0, react_1.useState)(false);
46
45
  const [hasDelayed, setHasDelayed] = (0, react_1.useState)(true);
47
46
  const [select, setSelect] = (0, react_1.useState)(start);
48
- const [hasPick, setHasPick] = (0, react_1.useState)(false);
47
+ const [hasDetail, setHasDetail] = (0, react_1.useState)(false);
49
48
  const refOuter = (0, react_1.useRef)(null);
50
- const refPicker = (0, react_1.useRef)(null);
49
+ const refDetail = (0, react_1.useRef)(null);
51
50
  const centralAngle = ((2 * Math.PI) / images.length) * (180 / Math.PI);
52
51
  // Functions of the rotation and select and delay.
53
52
  // turn left
54
53
  const shiftLeft = (0, react_1.useCallback)(() => {
55
54
  setSelect(select == 0 ? images.length - 1 : select - 1);
56
- setHasShift(false);
57
55
  setHasDelayed(false);
58
- if (dynamic)
59
- return setCount(count + centralAngle);
60
- }, [centralAngle, count, dynamic, images.length, select]);
56
+ setCount(count + centralAngle);
57
+ }, [centralAngle, count, images.length, select]);
61
58
  // turn right
62
59
  const shiftRight = (0, react_1.useCallback)(() => {
63
60
  setSelect(select == images.length - 1 ? 0 : select + 1);
64
- setHasShift(true);
65
61
  setHasDelayed(false);
66
- if (dynamic)
67
- return setCount(count - centralAngle);
68
- }, [centralAngle, count, dynamic, images.length, select]);
62
+ setCount(count - centralAngle);
63
+ }, [centralAngle, count, images.length, select]);
69
64
  // Function of the desktop.
70
65
  const handleScroll = (0, react_1.useCallback)((e) => {
71
66
  const delta = e.deltaY;
72
67
  if (delta < 0)
73
- scrollDirection ? shiftLeft() : shiftRight();
68
+ shiftLeft();
74
69
  if (delta > 0)
75
- scrollDirection ? shiftRight() : shiftLeft();
76
- }, [scrollDirection, shiftLeft, shiftRight]);
70
+ shiftRight();
71
+ }, [shiftLeft, shiftRight]);
77
72
  // Get a start y and x position in touchStart Y and X.
78
73
  const handleTouchStart = (e) => {
79
74
  const touch = e.touches[0];
@@ -123,12 +118,12 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
123
118
  setTouchStartY(deltaY);
124
119
  }, [shiftLeft, shiftRight, touchStartX, touchStartY]);
125
120
  const handleMouseDown = (0, react_1.useCallback)((e) => {
126
- if (hasPick)
121
+ if (hasDetail)
127
122
  return;
128
123
  setIsDragging(true);
129
124
  setInitialX(e.clientX);
130
125
  setInitialY(e.clientY);
131
- }, [hasPick]);
126
+ }, [hasDetail]);
132
127
  const handleMouseMove = (0, react_1.useCallback)((e) => {
133
128
  if (isDragging) {
134
129
  const outer = refOuter.current;
@@ -179,45 +174,45 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
179
174
  // Main functional, exit function if ref and hasDelayed does not exist.
180
175
  (0, react_1.useEffect)(() => {
181
176
  const outer = refOuter.current;
182
- const picker = refPicker.current;
177
+ const detail = refDetail.current;
183
178
  const timeId = setTimeout(() => {
184
179
  setHasDelayed(true);
185
- }, delay);
180
+ }, ((transition === null || transition === void 0 ? void 0 : transition.duration) / 2) * 1000);
186
181
  // Add handle event when component mount and deps update.
187
182
  document.addEventListener('mouseup', handleMouseUp);
188
183
  if (!hasDelayed)
189
184
  return;
190
- picker.addEventListener('mousedown', handleMouseDown);
185
+ detail.addEventListener('mousedown', handleMouseDown);
191
186
  outer.addEventListener('mousedown', handleMouseDown);
192
187
  document.addEventListener('mousemove', handleMouseMove);
193
188
  outer.addEventListener('wheel', handleScroll);
194
189
  outer.addEventListener('touchstart', handleTouchStart);
195
190
  outer.addEventListener('touchmove', handleTouchMove);
196
- picker.addEventListener('wheel', handleScroll);
197
- picker.addEventListener('touchstart', handleTouchStart);
198
- picker.addEventListener('touchmove', handleTouchMove);
191
+ detail.addEventListener('wheel', handleScroll);
192
+ detail.addEventListener('touchstart', handleTouchStart);
193
+ detail.addEventListener('touchmove', handleTouchMove);
199
194
  // Clean up event and timeId when component is unmount.
200
195
  return () => {
201
196
  clearTimeout(timeId);
202
197
  document.removeEventListener('mouseup', handleMouseUp);
203
- picker.removeEventListener('mousedown', handleMouseDown);
198
+ detail.removeEventListener('mousedown', handleMouseDown);
204
199
  outer.removeEventListener('mousedown', handleMouseDown);
205
200
  document.removeEventListener('mousemove', handleMouseMove);
206
201
  outer.removeEventListener('wheel', handleScroll);
207
202
  outer.removeEventListener('touchstart', handleTouchStart);
208
203
  outer.removeEventListener('touchmove', handleTouchMove);
209
- picker.removeEventListener('wheel', handleScroll);
210
- picker.removeEventListener('touchstart', handleTouchStart);
211
- picker.removeEventListener('touchmove', handleTouchMove);
204
+ detail.removeEventListener('wheel', handleScroll);
205
+ detail.removeEventListener('touchstart', handleTouchStart);
206
+ detail.removeEventListener('touchmove', handleTouchMove);
212
207
  };
213
208
  }, [
214
- delay,
215
209
  handleMouseDown,
216
210
  handleMouseMove,
217
211
  handleMouseUp,
218
212
  handleTouchMove,
219
213
  handleScroll,
220
- hasDelayed
214
+ hasDelayed,
215
+ transition === null || transition === void 0 ? void 0 : transition.duration
221
216
  ]);
222
217
  // The controll start or end.
223
218
  // Added event when component is mounted.
@@ -230,26 +225,26 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
230
225
  document.body.style.overflow = 'auto';
231
226
  };
232
227
  const outer = refOuter.current;
233
- const picker = refPicker.current;
228
+ const detail = refDetail.current;
234
229
  // Add event.
235
230
  outer.addEventListener('mouseover', enterControl, { passive: false });
236
231
  outer.addEventListener('mouseout', leaveControl);
237
232
  outer.addEventListener('touchmove', enterControl, { passive: false });
238
233
  outer.addEventListener('touchend', leaveControl);
239
- picker.addEventListener('mouseover', enterControl, { passive: false });
240
- picker.addEventListener('mouseout', leaveControl);
241
- picker.addEventListener('touchmove', enterControl, { passive: false });
242
- picker.addEventListener('touchend', leaveControl);
234
+ detail.addEventListener('mouseover', enterControl, { passive: false });
235
+ detail.addEventListener('mouseout', leaveControl);
236
+ detail.addEventListener('touchmove', enterControl, { passive: false });
237
+ detail.addEventListener('touchend', leaveControl);
243
238
  // Clean up event when component is unmount.
244
239
  return () => {
245
240
  outer.removeEventListener('mouseover', enterControl);
246
241
  outer.removeEventListener('mouseout', leaveControl);
247
242
  outer.removeEventListener('touchmove', enterControl);
248
243
  outer.removeEventListener('touchend', leaveControl);
249
- picker.removeEventListener('mouseover', enterControl);
250
- picker.removeEventListener('mouseout', leaveControl);
251
- picker.removeEventListener('touchmove', enterControl);
252
- picker.removeEventListener('touchend', leaveControl);
244
+ detail.removeEventListener('mouseover', enterControl);
245
+ detail.removeEventListener('mouseout', leaveControl);
246
+ detail.removeEventListener('touchmove', enterControl);
247
+ detail.removeEventListener('touchend', leaveControl);
253
248
  // page unmount with leave control.
254
249
  leaveControl();
255
250
  };
@@ -264,11 +259,14 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
264
259
  e.key === 'ArrowRight' && shiftLeft();
265
260
  e.key === 'ArrowDown' && shiftRight();
266
261
  e.key === 'ArrowLeft' && shiftRight();
267
- e.key === 'Enter' && setHasPick(true);
268
- e.key === 'Escape' && setHasPick(false);
262
+ e.key === 'Enter' && setHasDetail(true);
263
+ e.key === 'Escape' && setHasDetail(false);
269
264
  };
270
265
  // has after Lazy loading fade transition.
271
266
  const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
267
+ (0, react_1.useEffect)(() => {
268
+ setIsLoaded(true);
269
+ }, []);
272
270
  return (react_1.default.createElement(framer_motion_1.LazyMotion, { features: framer_motion_1.domAnimation },
273
271
  react_1.default.createElement("div", { className: className },
274
272
  react_1.default.createElement(framer_motion_1.m.div, { className: styles_module_css_1.default.outer, ref: refOuter, tabIndex: offsetIndex <= 0 ? 0 : offsetIndex - 1, onKeyDown: handleKeyPress, style: {
@@ -286,8 +284,8 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
286
284
  (hasSelect && classImageSelect) +
287
285
  ' ' +
288
286
  classImageUnique +
289
- zIndex, role: 'button', src: image.src, alt: image.alt, draggable: false, loading: loading, onLoad: () => setIsLoaded(true), animate: {
290
- rotate: -count,
287
+ zIndex, role: 'button', "aria-label": "click and scale image", src: image.src, alt: image.alt, draggable: false, loading: loading, animate: {
288
+ rotate: -count - ((animate === null || animate === void 0 ? void 0 : animate.rotate) ? animate === null || animate === void 0 ? void 0 : animate.rotate : 0),
291
289
  scale: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectScale : animate === null || animate === void 0 ? void 0 : animate.scale,
292
290
  rotateY: hasSelect
293
291
  ? animate === null || animate === void 0 ? void 0 : animate.selectRotateY
@@ -299,12 +297,12 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
299
297
  ? animate === null || animate === void 0 ? void 0 : animate.selectRotateZ
300
298
  : animate === null || animate === void 0 ? void 0 : animate.rotateZ,
301
299
  opacity: hasSelect
302
- ? hasPick
300
+ ? hasDetail
303
301
  ? 0
304
302
  : animate === null || animate === void 0 ? void 0 : animate.selectOpacity
305
303
  : animate === null || animate === void 0 ? void 0 : animate.opacity
306
304
  }, initial: {
307
- rotate: -count,
305
+ rotate: -count - ((initial === null || initial === void 0 ? void 0 : initial.rotate) ? initial === null || initial === void 0 ? void 0 : initial.rotate : 0),
308
306
  scale: hasSelect ? initial === null || initial === void 0 ? void 0 : initial.selectScale : initial === null || initial === void 0 ? void 0 : initial.scale,
309
307
  rotateY: hasSelect
310
308
  ? initial === null || initial === void 0 ? void 0 : initial.selectRotateY
@@ -318,7 +316,7 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
318
316
  opacity: hasSelect
319
317
  ? initial === null || initial === void 0 ? void 0 : initial.selectOpacity
320
318
  : initial === null || initial === void 0 ? void 0 : initial.opacity
321
- }, transition: transition, onPointerDown: () => setSelect(index), onClick: () => hasSelect && pickScale && !hasMove && setHasPick(true), style: {
319
+ }, transition: transition, onPointerDown: () => setSelect(index), onClick: () => hasSelect && detail && !hasMove && setHasDetail(true), style: {
322
320
  zIndex: hasSelect ? frontImage : zIndex,
323
321
  width: width + 'px',
324
322
  height: height + 'px',
@@ -330,14 +328,16 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
330
328
  radius -
331
329
  height / 2 +
332
330
  'px',
333
- filter: isLoaded
334
- ? 'blur(0)'
331
+ filter: initialFadeRange && isLoaded
332
+ ? ''
335
333
  : `blur(${initialFadeRange}px)`,
336
- transition: `filter ${initialTransTime}s ease-in-out`
334
+ transition: initialFadeTime
335
+ ? `filter ${initialFadeTime}s ease-in-out`
336
+ : ''
337
337
  } }));
338
338
  }))),
339
- react_1.default.createElement(PickImage_1.default, { onClick: () => {
340
- setHasPick(false);
341
- }, hasPick: hasPick, classPick: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.classPick, white: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.white, alpha: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.alpha, blur: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.blur, scale: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.scale, offset: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.offset, hasShift: hasShift, argRef: refPicker, argKey: select, src: images[select].src, alt: images[select].alt, width: width, height: height, transition: pickTransition, zIndex: frontImage }))));
339
+ react_1.default.createElement(DetailImage_1.DetailImage, { detailRef: refDetail, detailKey: select, hasDetail: hasDetail, onClick: () => {
340
+ setHasDetail(false);
341
+ }, classDetail: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.classDetail, src: images[select].src, alt: images[select].alt, width: width, height: height, white: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.white, alpha: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.alpha, blur: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.blur, scale: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.scale, transition: detailTransition, zIndex: frontImage }))));
342
342
  };
343
- exports.MagicCircle = MagicCircle;
343
+ exports.CircleRotation = CircleRotation;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { StraightInfinityProps } from '../types';
3
+ export declare const StraightInfinity: ({ images, start, height, width, vertical, margin, controller, offsetIndex, reverseIndex, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, detail, detailProperty, detailTransition, loading, initialFadeRange, initialFadeTime }: StraightInfinityProps) => React.JSX.Element;
@@ -22,16 +22,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
36
  };
28
37
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.MagicStraight = void 0;
38
+ exports.StraightInfinity = void 0;
30
39
  const react_1 = __importStar(require("react"));
31
40
  const framer_motion_1 = require("framer-motion");
32
41
  const styles_module_css_1 = __importDefault(require("./styles.module.css"));
33
- const PickImage_1 = __importDefault(require("../common/PickImage"));
34
- const MagicStraight = ({ images, start, height, width, vertical = true, margin = 0, selectOffsetX = 0, selectOffsetY = 0, controller, delay = 20, offsetIndex = 0, reverseIndex = true, loading, initialFadeRange = 4, initialTransTime = 0.2, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickScale = true, pickProperty, pickTransition }) => {
42
+ const DetailImage_1 = require("../common/DetailImage");
43
+ const StraightInfinity = ({ images, start, height, width, vertical = false, margin = 0, controller = 0, offsetIndex = 0, reverseIndex = true, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, detail = true, detailProperty, detailTransition, loading = 'lazy', initialFadeRange = 1, initialFadeTime = 0.2 }) => {
35
44
  // array out of range adjusting.
36
45
  start = Math.max(0, start);
37
46
  start = Math.min(start, images.length - 1);
@@ -44,30 +53,38 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
44
53
  const [hasShift, setHasShift] = (0, react_1.useState)(false);
45
54
  const [hasDelayed, setHasDelayed] = (0, react_1.useState)(true);
46
55
  const [select, setSelect] = (0, react_1.useState)(start);
47
- const [hasPick, setHasPick] = (0, react_1.useState)(false);
56
+ const [edge, setEdge] = (0, react_1.useState)(images.length);
57
+ const [hasDetail, setHasDetail] = (0, react_1.useState)(false);
48
58
  const refOuter = (0, react_1.useRef)(null);
49
- const refPicker = (0, react_1.useRef)(null);
59
+ const refDetail = (0, react_1.useRef)(null);
60
+ const [count, setCount] = (0, react_1.useState)(0);
50
61
  // Functions of the swipe and wheel a shifting.
51
62
  // turn left
52
- const shiftLeft = (0, react_1.useCallback)(() => {
53
- setSelect(select == 0 ? images.length - 1 : select - 1);
63
+ const shiftLeft = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
64
+ edge !== 0 && setSelect(select === 0 ? images.length - 1 : select - 1);
65
+ setEdge(edge === 0 ? images.length : edge - 1);
54
66
  setHasShift(false);
55
67
  setHasDelayed(false);
56
- }, [images.length, select]);
68
+ setCount(edge === 0 ? 5 : count + width + margin * 2);
69
+ return;
70
+ }), [count, images.length, margin, select, edge, width]);
57
71
  // turn right
58
- const shiftRight = (0, react_1.useCallback)(() => {
59
- setSelect(select == images.length - 1 ? 0 : select + 1);
72
+ const shiftRight = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
73
+ edge !== 5 && setSelect(select === images.length - 1 ? 0 : select + 1);
74
+ setEdge(edge === images.length ? 0 : edge + 1);
60
75
  setHasShift(true);
61
76
  setHasDelayed(false);
62
- }, [images.length, select]);
77
+ setCount(edge === 5 ? 0 : count - (width + margin * 2));
78
+ return;
79
+ }), [count, images.length, margin, select, edge, width]);
63
80
  // Wheel function of the desktop.
64
- const handleScroll = (0, react_1.useCallback)((e) => {
81
+ const handleScroll = (0, react_1.useCallback)((e) => __awaiter(void 0, void 0, void 0, function* () {
65
82
  const delta = e.deltaY;
66
83
  if (delta < 0)
67
84
  shiftLeft();
68
85
  if (delta > 0)
69
86
  shiftRight();
70
- }, [shiftLeft, shiftRight]);
87
+ }), [shiftLeft, shiftRight]);
71
88
  // Get a start y and x position in touchStart Y and X.
72
89
  const handleTouchStart = (e) => {
73
90
  const touch = e.touches[0];
@@ -77,29 +94,29 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
77
94
  // Swipe Function of the mobile.
78
95
  const handleTouchMove = (0, react_1.useCallback)((e) => {
79
96
  const touch = e.touches[0];
80
- const delta = hasPick
97
+ const delta = hasDetail
81
98
  ? touch.clientX
82
99
  : !vertical
83
100
  ? touch.clientX
84
101
  : touch.clientY;
85
- if (hasPick
102
+ if (hasDetail
86
103
  ? delta < touchStartX
87
104
  : !vertical
88
105
  ? delta < touchStartX
89
106
  : delta < touchStartY)
90
107
  shiftLeft();
91
- if (hasPick
108
+ if (hasDetail
92
109
  ? delta > touchStartX
93
110
  : !vertical
94
111
  ? delta > touchStartX
95
112
  : delta > touchStartY)
96
113
  shiftRight();
97
- hasPick
114
+ hasDetail
98
115
  ? setTouchStartX(delta)
99
116
  : !vertical
100
117
  ? setTouchStartX(delta)
101
118
  : setTouchStartY(delta);
102
- }, [hasPick, shiftLeft, shiftRight, touchStartX, touchStartY, vertical]);
119
+ }, [hasDetail, shiftLeft, shiftRight, touchStartX, touchStartY, vertical]);
103
120
  const handleMouseDown = (0, react_1.useCallback)((e) => {
104
121
  setIsDragging(true);
105
122
  setInitialX(e.clientX);
@@ -124,23 +141,23 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
124
141
  // Main functional, exit function if ref and hasDelayed does not exist.
125
142
  (0, react_1.useEffect)(() => {
126
143
  const outer = refOuter.current;
127
- const picker = refPicker.current;
144
+ const detail = refDetail.current;
128
145
  const timeId = setTimeout(() => {
129
146
  setHasDelayed(true);
130
- }, delay);
147
+ }, ((transition === null || transition === void 0 ? void 0 : transition.duration) / 2) * 1000);
131
148
  // Add handle event when component mount and deps update.
132
149
  document.addEventListener('mouseup', handleMouseUp);
133
150
  if (!hasDelayed)
134
151
  return;
135
- picker.addEventListener('mousedown', handleMouseDown);
152
+ detail.addEventListener('mousedown', handleMouseDown);
136
153
  outer.addEventListener('mousedown', handleMouseDown);
137
154
  document.addEventListener('mousemove', handleMouseMove);
138
155
  outer.addEventListener('wheel', handleScroll);
139
156
  outer.addEventListener('touchstart', handleTouchStart);
140
157
  outer.addEventListener('touchmove', handleTouchMove);
141
- picker.addEventListener('wheel', handleScroll);
142
- picker.addEventListener('touchstart', handleTouchStart);
143
- picker.addEventListener('touchmove', handleTouchMove);
158
+ detail.addEventListener('wheel', handleScroll);
159
+ detail.addEventListener('touchstart', handleTouchStart);
160
+ detail.addEventListener('touchmove', handleTouchMove);
144
161
  // Clean up event and timeId when component is unmount.
145
162
  return () => {
146
163
  clearTimeout(timeId);
@@ -148,20 +165,20 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
148
165
  outer.removeEventListener('touchstart', handleTouchStart);
149
166
  outer.removeEventListener('touchmove', handleTouchMove);
150
167
  document.removeEventListener('mouseup', handleMouseUp);
151
- picker.removeEventListener('mousedown', handleMouseDown);
168
+ detail.removeEventListener('mousedown', handleMouseDown);
152
169
  outer.removeEventListener('mousedown', handleMouseDown);
153
170
  document.removeEventListener('mousemove', handleMouseMove);
154
- picker.removeEventListener('touchstart', handleTouchStart);
155
- picker.removeEventListener('touchmove', handleTouchMove);
171
+ detail.removeEventListener('touchstart', handleTouchStart);
172
+ detail.removeEventListener('touchmove', handleTouchMove);
156
173
  };
157
174
  }, [
158
- delay,
159
175
  handleMouseDown,
160
176
  handleMouseMove,
161
177
  handleMouseUp,
162
178
  handleTouchMove,
163
179
  handleScroll,
164
- hasDelayed
180
+ hasDelayed,
181
+ transition === null || transition === void 0 ? void 0 : transition.duration
165
182
  ]);
166
183
  // The controll start or end.
167
184
  // Added event when component is mounted.
@@ -174,35 +191,30 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
174
191
  document.body.style.overflow = 'auto';
175
192
  };
176
193
  const outer = refOuter.current;
177
- const picker = refPicker.current;
194
+ const detail = refDetail.current;
178
195
  // Add event.
179
196
  outer.addEventListener('mouseover', enterControl, { passive: false });
180
197
  outer.addEventListener('mouseout', leaveControl);
181
198
  outer.addEventListener('touchmove', enterControl, { passive: false });
182
199
  outer.addEventListener('touchend', leaveControl);
183
- picker.addEventListener('mouseover', enterControl, { passive: false });
184
- picker.addEventListener('mouseout', leaveControl);
185
- picker.addEventListener('touchmove', enterControl, { passive: false });
186
- picker.addEventListener('touchend', leaveControl);
200
+ detail.addEventListener('mouseover', enterControl, { passive: false });
201
+ detail.addEventListener('mouseout', leaveControl);
202
+ detail.addEventListener('touchmove', enterControl, { passive: false });
203
+ detail.addEventListener('touchend', leaveControl);
187
204
  // Clean up event when component is unmount.
188
205
  return () => {
189
206
  outer.removeEventListener('mouseover', enterControl);
190
207
  outer.removeEventListener('mouseout', leaveControl);
191
208
  outer.removeEventListener('touchmove', enterControl);
192
209
  outer.removeEventListener('touchend', leaveControl);
193
- picker.removeEventListener('mouseover', enterControl);
194
- picker.removeEventListener('mouseout', leaveControl);
195
- picker.removeEventListener('touchmove', enterControl);
196
- picker.removeEventListener('touchend', leaveControl);
210
+ detail.removeEventListener('mouseover', enterControl);
211
+ detail.removeEventListener('mouseout', leaveControl);
212
+ detail.removeEventListener('touchmove', enterControl);
213
+ detail.removeEventListener('touchend', leaveControl);
197
214
  // page unmount with leave control.
198
215
  leaveControl();
199
216
  };
200
217
  }, []);
201
- // average calculation.
202
- let total = 0;
203
- for (let i = 1; i < images.length; i++)
204
- total += i;
205
- const average = total / images.length;
206
218
  // selected image.
207
219
  const frontImage = offsetIndex + images.length + 1;
208
220
  // keyboard control.
@@ -211,24 +223,71 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
211
223
  e.key === 'ArrowUp' && shiftLeft();
212
224
  e.key === 'ArrowRight' && shiftRight();
213
225
  e.key === 'ArrowDown' && shiftRight();
214
- e.key === 'Enter' && setHasPick(true);
215
- e.key === 'Escape' && setHasPick(false);
226
+ e.key === 'Enter' && setHasDetail(true);
227
+ e.key === 'Escape' && setHasDetail(false);
216
228
  };
217
229
  // has after Lazy loading fade transition.
218
230
  const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
231
+ (0, react_1.useEffect)(() => {
232
+ setIsLoaded(true);
233
+ }, []);
234
+ const [offsetWide, setOffsetWide] = (0, react_1.useState)(0);
235
+ const [offsetHeight, setOffsetHeight] = (0, react_1.useState)(0);
236
+ (0, react_1.useLayoutEffect)(() => {
237
+ if (edge === 0 && hasShift == true) {
238
+ if (!vertical)
239
+ setOffsetWide(images.length * width + images.length * (margin * 2));
240
+ if (vertical)
241
+ setOffsetHeight(images.length * height + images.length * (margin * 2));
242
+ }
243
+ if (edge === 5 && hasShift == false) {
244
+ if (!vertical)
245
+ setOffsetWide(0);
246
+ if (vertical)
247
+ setOffsetHeight(0);
248
+ }
249
+ }, [
250
+ hasDelayed,
251
+ hasShift,
252
+ height,
253
+ images.length,
254
+ margin,
255
+ edge,
256
+ vertical,
257
+ width
258
+ ]);
259
+ (0, react_1.useLayoutEffect)(() => {
260
+ if (edge === 0 && hasShift == false) {
261
+ shiftLeft();
262
+ }
263
+ if (edge === 0 && hasShift == true) {
264
+ shiftRight();
265
+ }
266
+ }, [hasDelayed, hasShift, shiftLeft, shiftRight, edge]);
219
267
  return (react_1.default.createElement(framer_motion_1.LazyMotion, { features: framer_motion_1.domAnimation },
220
268
  react_1.default.createElement("div", { className: className },
221
- react_1.default.createElement("div", { className: styles_module_css_1.default.outer, ref: refOuter, tabIndex: offsetIndex <= 0 ? 0 : offsetIndex - 1, onKeyDown: handleKeyPress, style: {
269
+ react_1.default.createElement(framer_motion_1.m.div, { className: styles_module_css_1.default.outer, ref: refOuter, tabIndex: offsetIndex <= 0 ? 0 : offsetIndex - 1, onKeyDown: handleKeyPress, style: {
222
270
  zIndex: offsetIndex - 1,
223
271
  width: !vertical
224
- ? images.length * (width + margin * 2) + controller + 'px'
272
+ ? images.length * (width + margin * 2) * 6 + controller + 'px'
225
273
  : width + controller,
226
274
  height: vertical
227
- ? images.length * (height + margin * 2) + controller + 'px'
275
+ ? images.length * (height + margin * 2) * 6 + controller + 'px'
228
276
  : height + controller,
229
277
  flexDirection: vertical ? 'column' : 'row'
230
- } }, images.map((image, index) => {
278
+ }, animate: {
279
+ x: !vertical ? count + offsetWide : 0,
280
+ y: vertical ? count + offsetHeight : 0
281
+ }, transition: transition }, images.map((image, index) => {
231
282
  const hasSelect = images[select] == images[index];
283
+ const hasEdge = () => {
284
+ for (let i = edge; i <= images.length - 1; i++) {
285
+ if (images[i] === images[index]) {
286
+ return true;
287
+ }
288
+ }
289
+ return false;
290
+ };
232
291
  const zIndex = reverseIndex
233
292
  ? offsetIndex + images.length - 1 - index
234
293
  : offsetIndex + index;
@@ -237,22 +296,15 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
237
296
  (hasSelect && classImageSelect) +
238
297
  ' ' +
239
298
  classImageUnique +
240
- index, src: image.src, alt: image.alt, role: 'button', draggable: false, loading: loading, onLoad: () => setIsLoaded(true), animate: {
241
- y: hasSelect
242
- ? vertical
243
- ? (average - index) * height +
244
- (average - index) * (margin * 2) +
245
- selectOffsetY
246
- : selectOffsetY
299
+ index, src: image.src, alt: image.alt, role: 'button', "aria-label": "click and scale image", draggable: false, loading: loading, animate: {
300
+ x: !vertical && hasEdge()
301
+ ? -(images.length * width + images.length * (margin * 2))
247
302
  : 0,
248
- x: hasSelect
249
- ? !vertical
250
- ? (average - index) * width +
251
- (average - index) * (margin * 2) +
252
- selectOffsetX
253
- : selectOffsetX
303
+ y: vertical && hasEdge()
304
+ ? -(images.length * height + images.length * (margin * 2))
254
305
  : 0,
255
306
  scale: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectScale : animate === null || animate === void 0 ? void 0 : animate.scale,
307
+ rotate: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectRotate : animate === null || animate === void 0 ? void 0 : animate.rotate,
256
308
  rotateY: hasSelect
257
309
  ? animate === null || animate === void 0 ? void 0 : animate.selectRotateY
258
310
  : animate === null || animate === void 0 ? void 0 : animate.rotateY,
@@ -262,13 +314,16 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
262
314
  rotateZ: hasSelect
263
315
  ? animate === null || animate === void 0 ? void 0 : animate.selectRotateZ
264
316
  : animate === null || animate === void 0 ? void 0 : animate.rotateZ,
265
- opacity: hasSelect
266
- ? hasPick
267
- ? 0
268
- : animate === null || animate === void 0 ? void 0 : animate.selectOpacity
269
- : animate === null || animate === void 0 ? void 0 : animate.opacity
317
+ opacity: images[images[edge] === images[images.length] ? 0 : edge] === images[index] || images[edge - 1] === images[index]
318
+ ? 0
319
+ : hasSelect
320
+ ? hasDetail
321
+ ? 0
322
+ : animate === null || animate === void 0 ? void 0 : animate.selectOpacity
323
+ : animate === null || animate === void 0 ? void 0 : animate.opacity
270
324
  }, initial: {
271
325
  scale: hasSelect ? initial === null || initial === void 0 ? void 0 : initial.selectScale : initial === null || initial === void 0 ? void 0 : initial.scale,
326
+ rotate: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectRotate : animate === null || animate === void 0 ? void 0 : animate.rotate,
272
327
  rotateY: hasSelect
273
328
  ? initial === null || initial === void 0 ? void 0 : initial.selectRotateY
274
329
  : initial === null || initial === void 0 ? void 0 : initial.rotateY,
@@ -280,8 +335,17 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
280
335
  : initial === null || initial === void 0 ? void 0 : initial.rotateZ,
281
336
  opacity: hasSelect ? initial === null || initial === void 0 ? void 0 : initial.selectOpacity : initial === null || initial === void 0 ? void 0 : initial.opacity
282
337
  }, transition: transition, onClick: () => {
283
- setSelect(index);
284
- hasSelect && pickScale && !hasMove && setHasPick(true);
338
+ hasSelect && detail && !hasMove && setHasDetail(true);
339
+ if (!hasDelayed)
340
+ return;
341
+ images[select - 1] === images[index] ||
342
+ (select === 0 && images[images.length - 1] === images[index])
343
+ ? shiftLeft()
344
+ : images[select + 1] === images[index] ||
345
+ (select === images.length - 1 &&
346
+ images[0] === images[index])
347
+ ? shiftRight()
348
+ : null;
285
349
  }, style: {
286
350
  zIndex: hasSelect ? frontImage : zIndex,
287
351
  width: width + 'px',
@@ -289,12 +353,17 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
289
353
  margin: vertical
290
354
  ? margin + 'px' + ' 0'
291
355
  : '0 ' + margin + 'px',
292
- filter: isLoaded ? 'blur(0)' : `blur(${initialFadeRange}px)`,
293
- transition: `filter ${initialTransTime}s ease-in-out`
356
+ filter: initialFadeRange && isLoaded
357
+ ? ''
358
+ : `blur(${initialFadeRange}px)`,
359
+ transition: initialFadeTime
360
+ ? `filter ${initialFadeTime}s ease-in-out`
361
+ : ''
294
362
  } }));
295
363
  })),
296
- react_1.default.createElement(PickImage_1.default, { classPick: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.classPick, argRef: refPicker, onClick: () => {
297
- setHasPick(false);
298
- }, hasPick: hasPick, white: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.white, alpha: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.alpha, blur: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.blur, scale: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.scale, offset: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.offset, hasShift: hasShift, argKey: select, src: images[select].src, alt: images[select].alt, width: width, height: height, transition: pickTransition, zIndex: frontImage }))));
364
+ react_1.default.createElement(DetailImage_1.DetailImage, { detailRef: refDetail, detailKey: select, hasDetail: hasDetail, onClick: () => {
365
+ setHasDetail(false);
366
+ }, classDetail: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.classDetail, src: images[select].src, alt: images[select].alt, width: width, height: height, white: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.white, alpha: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.alpha, blur: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.blur, scale: detailProperty === null || detailProperty === void 0 ? void 0 : detailProperty.scale, transition: detailTransition, zIndex: frontImage }),
367
+ react_1.default.createElement(react_1.default.Fragment, null, select))));
299
368
  };
300
- exports.MagicStraight = MagicStraight;
369
+ exports.StraightInfinity = StraightInfinity;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { DetailImageProps } from '../../types';
3
+ export declare const DetailImage: ({ onClick, classDetail, hasDetail, detailRef, detailKey, src, alt, width, height, zIndex, white, alpha, blur, scale, transition }: DetailImageProps) => React.JSX.Element;
@@ -3,26 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DetailImage = void 0;
6
7
  const react_1 = __importDefault(require("react"));
7
8
  const framer_motion_1 = require("framer-motion");
8
9
  const styles_module_css_1 = __importDefault(require("./styles.module.css"));
9
- const PickImage = ({ onClick, classPick, hasPick, hasShift, argRef, argKey, src, alt, width, height, zIndex, white = true, alpha = 0.4, blur = 4, scale = 2, offset = 0, transition }) => {
10
- const backdropFilter = hasPick ? `blur(${blur}px)` : undefined;
11
- const background = hasPick
10
+ const DetailImage = ({ onClick, classDetail, hasDetail, detailRef, detailKey, src, alt, width, height, zIndex, white = true, alpha = 0.3, blur = 3, scale = 2.5, transition }) => {
11
+ const backdropFilter = hasDetail ? `blur(${blur}px)` : undefined;
12
+ const background = hasDetail
12
13
  ? white
13
14
  ? `rgba(255, 255, 255, ${alpha})`
14
15
  : `rgba(0, 0, 0, ${alpha})`
15
16
  : undefined;
16
- return (react_1.default.createElement(framer_motion_1.m.div, { role: "button", onClick: onClick, ref: argRef, className: styles_module_css_1.default.full_size, animate: {
17
+ return (react_1.default.createElement(framer_motion_1.m.div, { role: "button", onClick: onClick, ref: detailRef, className: styles_module_css_1.default.full_size, animate: {
17
18
  zIndex: zIndex,
18
- opacity: hasPick ? 1 : 0,
19
- pointerEvents: hasPick ? 'auto' : 'none'
19
+ opacity: hasDetail ? 1 : 0,
20
+ pointerEvents: hasDetail ? 'auto' : 'none'
20
21
  }, style: { backdropFilter: backdropFilter, background: background }, transition: transition },
21
- react_1.default.createElement(framer_motion_1.m.img, { key: argKey, className: classPick + ' ' + styles_module_css_1.default.no_select, src: src, alt: alt, width: width, height: height, draggable: false, animate: {
22
+ react_1.default.createElement(framer_motion_1.m.img, { key: detailKey, className: classDetail + ' ' + styles_module_css_1.default.no_select, src: src, alt: alt, width: width, height: height, draggable: false, animate: {
22
23
  zIndex: zIndex + 1,
23
24
  scale: scale,
24
- opacity: hasPick ? 1 : 0,
25
+ opacity: hasDetail ? 1 : 0,
25
26
  x: 0
26
- }, initial: { scale: 1, opacity: 0, x: hasShift ? offset : -offset }, transition: transition })));
27
+ }, initial: { scale: 1, opacity: 0 }, transition: transition })));
27
28
  };
28
- exports.default = PickImage;
29
+ exports.DetailImage = DetailImage;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MagicCircle } from './MagicCircle';
2
- import { MagicStraight } from './MagicStraight';
3
- export { MagicCircle };
4
- export { MagicStraight };
1
+ import { CircleRotation } from './CircleRotation';
2
+ import { StraightInfinity } from './StraightInfinity';
3
+ export { CircleRotation };
4
+ export { StraightInfinity };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MagicStraight = exports.MagicCircle = void 0;
4
- const MagicCircle_1 = require("./MagicCircle");
5
- Object.defineProperty(exports, "MagicCircle", { enumerable: true, get: function () { return MagicCircle_1.MagicCircle; } });
6
- const MagicStraight_1 = require("./MagicStraight");
7
- Object.defineProperty(exports, "MagicStraight", { enumerable: true, get: function () { return MagicStraight_1.MagicStraight; } });
3
+ exports.StraightInfinity = exports.CircleRotation = void 0;
4
+ const CircleRotation_1 = require("./CircleRotation");
5
+ Object.defineProperty(exports, "CircleRotation", { enumerable: true, get: function () { return CircleRotation_1.CircleRotation; } });
6
+ const StraightInfinity_1 = require("./StraightInfinity");
7
+ Object.defineProperty(exports, "StraightInfinity", { enumerable: true, get: function () { return StraightInfinity_1.StraightInfinity; } });
package/dist/types.d.ts CHANGED
@@ -5,11 +5,13 @@ type ImageProperty = {
5
5
  };
6
6
  type AnimationProperty = {
7
7
  scale?: number;
8
+ rotate?: number;
8
9
  rotateY?: number;
9
10
  rotateX?: number;
10
11
  rotateZ?: number;
11
12
  opacity?: number;
12
13
  selectScale?: number;
14
+ selectRotate?: number;
13
15
  selectRotateY?: number;
14
16
  selectRotateX?: number;
15
17
  selectRotateZ?: number;
@@ -26,12 +28,9 @@ type TransitionProperty = {
26
28
  damping?: number;
27
29
  mass?: number;
28
30
  stiffness?: number;
29
- velocity?: number;
30
- restSpeed?: number;
31
- restDelta?: number;
32
31
  };
33
- type PickProperty = {
34
- classPick?: string;
32
+ type DetailProperty = {
33
+ classDetail?: string;
35
34
  white?: boolean;
36
35
  alpha?: number;
37
36
  blur?: number;
@@ -41,15 +40,11 @@ type PickProperty = {
41
40
  type CommonProperty = {
42
41
  images: ImageProperty[];
43
42
  start: number;
44
- loading?: 'eager' | 'lazy';
45
43
  height: number;
46
44
  width: number;
47
45
  controller: number;
48
- delay: number;
49
46
  offsetIndex?: number;
50
47
  reverseIndex?: boolean;
51
- initialFadeRange: number;
52
- initialTransTime: number;
53
48
  className?: string;
54
49
  classImages?: string;
55
50
  classImageSelect?: string;
@@ -57,36 +52,36 @@ type CommonProperty = {
57
52
  animate?: AnimationProperty;
58
53
  initial?: AnimationProperty;
59
54
  transition?: TransitionProperty;
55
+ loading?: 'eager' | 'lazy';
56
+ initialFadeRange?: number;
57
+ initialFadeTime?: number;
60
58
  };
61
- type OffPick = {
62
- pickScale?: true;
63
- pickProperty: PickProperty;
64
- pickTransition: TransitionProperty;
59
+ type DetailOn = {
60
+ detail?: true;
61
+ detailProperty: DetailProperty;
62
+ detailTransition: TransitionProperty;
65
63
  };
66
- type OnPick = {
67
- pickScale?: false;
68
- pickProperty?: undefined;
69
- pickTransition?: undefined;
64
+ type DetailOff = {
65
+ detail?: false;
66
+ detailProperty?: undefined;
67
+ detailTransition?: undefined;
70
68
  };
71
- type MagicProperty = CommonProperty & (OffPick | OnPick);
72
- export type MagicCircleProps = MagicProperty & {
69
+ type MagicProperty = CommonProperty & (DetailOn | DetailOff);
70
+ export type CircleRotationProps = MagicProperty & {
73
71
  radius: number;
74
- dynamic?: boolean;
75
- scrollDirection?: boolean;
76
72
  };
77
- export type MagicStraightProps = MagicProperty & {
73
+ export type StraightInfinityProps = MagicProperty & {
78
74
  vertical?: boolean;
79
75
  margin?: number;
80
76
  selectOffsetX?: number;
81
77
  selectOffsetY?: number;
82
78
  };
83
- export type PickImageProps = {
79
+ export type DetailImageProps = {
84
80
  onClick: MouseEventHandler<HTMLDivElement>;
85
- classPick?: string;
86
- hasPick: boolean;
87
- hasShift: boolean;
88
- argRef: Ref<HTMLDivElement>;
89
- argKey: number;
81
+ classDetail?: string;
82
+ hasDetail: boolean;
83
+ detailRef: Ref<HTMLDivElement>;
84
+ detailKey: number;
90
85
  src: string;
91
86
  alt: string;
92
87
  width: number;
@@ -96,7 +91,6 @@ export type PickImageProps = {
96
91
  alpha?: number;
97
92
  blur?: number;
98
93
  scale?: number;
99
- offset?: number;
100
94
  transition?: TransitionProperty;
101
95
  };
102
96
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-magic-card",
3
- "version": "1.1.2",
3
+ "version": "2.0.0",
4
4
  "description": "React Component library for images gallery using the framer motion animation.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -23,7 +23,9 @@
23
23
  "component",
24
24
  "animation",
25
25
  "images",
26
- "gallery"
26
+ "gallery",
27
+ "circle",
28
+ "infinity"
27
29
  ],
28
30
  "license": "MIT",
29
31
  "dependencies": {
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import type { MagicCircleProps } from '../types';
3
- export declare const MagicCircle: ({ images, start, height, width, dynamic, scrollDirection, radius, delay, controller, offsetIndex, reverseIndex, loading, initialFadeRange, initialTransTime, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickScale, pickProperty, pickTransition }: MagicCircleProps) => React.JSX.Element;
@@ -1,14 +0,0 @@
1
- .outer {
2
- display: flex;
3
- align-items: center;
4
- justify-content: center;
5
- user-select: none;
6
- }
7
-
8
- .inner {
9
- position: relative;
10
- }
11
-
12
- .inner img {
13
- position: absolute;
14
- }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import type { MagicStraightProps } from '../types';
3
- export declare const MagicStraight: ({ images, start, height, width, vertical, margin, selectOffsetX, selectOffsetY, controller, delay, offsetIndex, reverseIndex, loading, initialFadeRange, initialTransTime, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickScale, pickProperty, pickTransition }: MagicStraightProps) => React.JSX.Element;
@@ -1,6 +0,0 @@
1
- .outer {
2
- display: flex;
3
- align-items: center;
4
- justify-content: center;
5
- user-select: none;
6
- }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { PickImageProps } from '../../types';
3
- declare const PickImage: ({ onClick, classPick, hasPick, hasShift, argRef, argKey, src, alt, width, height, zIndex, white, alpha, blur, scale, offset, transition }: PickImageProps) => React.JSX.Element;
4
- export default PickImage;
@@ -1,14 +0,0 @@
1
- .full_size {
2
- position: fixed;
3
- top: 0;
4
- left: 0;
5
- display: flex;
6
- align-items: center;
7
- justify-content: center;
8
- width: 100%;
9
- height: 100%;
10
- }
11
-
12
- .no_select {
13
- user-select: none;
14
- }