react-magic-card 1.1.0 → 1.1.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/README.md CHANGED
@@ -51,8 +51,9 @@ function MyComponent() {
51
51
  | delay | delay of the animation firing interval |
52
52
  | offsetIndex | add an offset to the index of the components and images |
53
53
  | reverseIndex | order the change the overlap of zindex default true |
54
- | fadeRange | range of fade animation after page loaded |
55
- | transTime | transition time of fade animation after page loaded |
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 |
56
57
  | className | className of the component |
57
58
  | classImages | className of the images |
58
59
  | classImageSelect | className of the select image |
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import type { MagicCircleProps } from '../types';
3
- export declare const MagicCircle: ({ images, start, height, width, dynamic, scrollDirection, radius, delay, controller, offsetIndex, reverseIndex, fadeRange, transTime, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickScale, pickProperty, pickTransition }: MagicCircleProps) => React.JSX.Element;
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;
@@ -31,7 +31,7 @@ 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
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, fadeRange = 4, transTime = 0.2, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickScale = true, pickProperty, pickTransition }) => {
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 }) => {
35
35
  // array out of range adjusting.
36
36
  start = Math.max(0, start);
37
37
  start = Math.min(start, images.length - 1);
@@ -289,7 +289,7 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
289
289
  (hasSelect && classImageSelect) +
290
290
  ' ' +
291
291
  classImageUnique +
292
- zIndex, role: 'button', src: image.src, alt: image.alt, draggable: false, loading: 'lazy', animate: {
292
+ zIndex, role: 'button', src: image.src, alt: image.alt, draggable: false, loading: loading, animate: {
293
293
  rotate: -count,
294
294
  scale: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectScale : animate === null || animate === void 0 ? void 0 : animate.scale,
295
295
  rotateY: hasSelect
@@ -321,7 +321,7 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
321
321
  opacity: hasSelect
322
322
  ? initial === null || initial === void 0 ? void 0 : initial.selectOpacity
323
323
  : initial === null || initial === void 0 ? void 0 : initial.opacity
324
- }, transition: transition, onMouseDown: () => setSelect(index), onPointerDown: () => setSelect(index), onClick: () => hasSelect && pickScale && !hasMove && setHasPick(true), style: {
324
+ }, transition: transition, onPointerDown: () => setSelect(index), onClick: () => hasSelect && pickScale && !hasMove && setHasPick(true), style: {
325
325
  zIndex: hasSelect ? frontImage : zIndex,
326
326
  width: width + 'px',
327
327
  height: height + 'px',
@@ -333,8 +333,10 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
333
333
  radius -
334
334
  height / 2 +
335
335
  'px',
336
- filter: isLoaded ? 'blur(0)' : `blur(${fadeRange}px)`,
337
- transition: `filter ${transTime}s ease-in-out`
336
+ filter: isLoaded
337
+ ? 'blur(0)'
338
+ : `blur(${initialFadeRange}px)`,
339
+ transition: `filter ${initialTransTime}s ease-in-out`
338
340
  } }));
339
341
  }))),
340
342
  react_1.default.createElement(PickImage_1.default, { onClick: () => {
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import type { MagicStraightProps } from '../types';
3
- export declare const MagicStraight: ({ images, start, height, width, vertical, margin, selectOffsetX, selectOffsetY, controller, delay, offsetIndex, reverseIndex, fadeRange, transTime, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickScale, pickProperty, pickTransition }: MagicStraightProps) => React.JSX.Element;
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;
@@ -31,7 +31,7 @@ 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
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, fadeRange = 4, transTime = 0.2, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickScale = true, pickProperty, pickTransition }) => {
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 }) => {
35
35
  // array out of range adjusting.
36
36
  start = Math.max(0, start);
37
37
  start = Math.min(start, images.length - 1);
@@ -40,6 +40,7 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
40
40
  const [initialX, setInitialX] = (0, react_1.useState)(0);
41
41
  const [initialY, setInitialY] = (0, react_1.useState)(0);
42
42
  const [isDragging, setIsDragging] = (0, react_1.useState)(false);
43
+ const [hasMove, setHasMove] = (0, react_1.useState)(false);
43
44
  const [hasShift, setHasShift] = (0, react_1.useState)(false);
44
45
  const [hasDelayed, setHasDelayed] = (0, react_1.useState)(true);
45
46
  const [select, setSelect] = (0, react_1.useState)(start);
@@ -113,10 +114,12 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
113
114
  if (!vertical ? deltaX > 0 : deltaY > 0)
114
115
  shiftRight();
115
116
  !vertical ? setInitialX(e.clientX) : setInitialY(e.clientY);
117
+ setHasMove(true);
116
118
  }
117
119
  }, [initialX, initialY, isDragging, shiftLeft, shiftRight, vertical]);
118
120
  const handleMouseUp = (0, react_1.useCallback)(() => {
119
121
  setIsDragging(false);
122
+ setHasMove(false);
120
123
  }, []);
121
124
  // Main functional, exit function if ref and hasDelayed does not exist.
122
125
  (0, react_1.useEffect)(() => {
@@ -237,7 +240,7 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
237
240
  (hasSelect && classImageSelect) +
238
241
  ' ' +
239
242
  classImageUnique +
240
- index, src: image.src, alt: image.alt, role: 'button', draggable: false, loading: 'lazy', animate: {
243
+ index, src: image.src, alt: image.alt, role: 'button', draggable: false, loading: loading, animate: {
241
244
  y: hasSelect
242
245
  ? vertical
243
246
  ? (average - index) * height +
@@ -281,7 +284,7 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
281
284
  opacity: hasSelect ? initial === null || initial === void 0 ? void 0 : initial.selectOpacity : initial === null || initial === void 0 ? void 0 : initial.opacity
282
285
  }, transition: transition, onClick: () => {
283
286
  setSelect(index);
284
- hasSelect && pickScale && !isDragging && setHasPick(true);
287
+ hasSelect && pickScale && !hasMove && setHasPick(true);
285
288
  }, style: {
286
289
  zIndex: hasSelect ? frontImage : zIndex,
287
290
  width: width + 'px',
@@ -289,8 +292,8 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
289
292
  margin: vertical
290
293
  ? margin + 'px' + ' 0'
291
294
  : '0 ' + margin + 'px',
292
- filter: isLoaded ? 'blur(0)' : `blur(${fadeRange}px)`,
293
- transition: `filter ${transTime}s ease-in-out`
295
+ filter: isLoaded ? 'blur(0)' : `blur(${initialFadeRange}px)`,
296
+ transition: `filter ${initialTransTime}s ease-in-out`
294
297
  } }));
295
298
  })),
296
299
  react_1.default.createElement(PickImage_1.default, { classPick: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.classPick, argRef: refPicker, onClick: () => {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  const framer_motion_1 = require("framer-motion");
8
8
  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 = 200, transition }) => {
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
10
  const backdropFilter = hasPick ? `blur(${blur}px)` : undefined;
11
11
  const background = hasPick
12
12
  ? white
package/dist/types.d.ts CHANGED
@@ -41,14 +41,15 @@ type PickProperty = {
41
41
  type CommonProperty = {
42
42
  images: ImageProperty[];
43
43
  start: number;
44
+ loading?: 'eager' | 'lazy';
44
45
  height: number;
45
46
  width: number;
46
47
  controller: number;
47
48
  delay: number;
48
49
  offsetIndex?: number;
49
50
  reverseIndex?: boolean;
50
- fadeRange: number;
51
- transTime: number;
51
+ initialFadeRange: number;
52
+ initialTransTime: number;
52
53
  className?: string;
53
54
  classImages?: string;
54
55
  classImageSelect?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-magic-card",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
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",