react-magic-card 1.1.0 → 1.1.2

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);
@@ -269,9 +269,6 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
269
269
  };
270
270
  // has after Lazy loading fade transition.
271
271
  const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
272
- (0, react_1.useEffect)(() => {
273
- setIsLoaded(true);
274
- }, []);
275
272
  return (react_1.default.createElement(framer_motion_1.LazyMotion, { features: framer_motion_1.domAnimation },
276
273
  react_1.default.createElement("div", { className: className },
277
274
  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: {
@@ -289,7 +286,7 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
289
286
  (hasSelect && classImageSelect) +
290
287
  ' ' +
291
288
  classImageUnique +
292
- zIndex, role: 'button', src: image.src, alt: image.alt, draggable: false, loading: 'lazy', animate: {
289
+ zIndex, role: 'button', src: image.src, alt: image.alt, draggable: false, loading: loading, onLoad: () => setIsLoaded(true), animate: {
293
290
  rotate: -count,
294
291
  scale: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectScale : animate === null || animate === void 0 ? void 0 : animate.scale,
295
292
  rotateY: hasSelect
@@ -321,7 +318,7 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
321
318
  opacity: hasSelect
322
319
  ? initial === null || initial === void 0 ? void 0 : initial.selectOpacity
323
320
  : 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: {
321
+ }, transition: transition, onPointerDown: () => setSelect(index), onClick: () => hasSelect && pickScale && !hasMove && setHasPick(true), style: {
325
322
  zIndex: hasSelect ? frontImage : zIndex,
326
323
  width: width + 'px',
327
324
  height: height + 'px',
@@ -333,8 +330,10 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
333
330
  radius -
334
331
  height / 2 +
335
332
  'px',
336
- filter: isLoaded ? 'blur(0)' : `blur(${fadeRange}px)`,
337
- transition: `filter ${transTime}s ease-in-out`
333
+ filter: isLoaded
334
+ ? 'blur(0)'
335
+ : `blur(${initialFadeRange}px)`,
336
+ transition: `filter ${initialTransTime}s ease-in-out`
338
337
  } }));
339
338
  }))),
340
339
  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)(() => {
@@ -213,9 +216,6 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
213
216
  };
214
217
  // has after Lazy loading fade transition.
215
218
  const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
216
- (0, react_1.useEffect)(() => {
217
- setIsLoaded(true);
218
- }, []);
219
219
  return (react_1.default.createElement(framer_motion_1.LazyMotion, { features: framer_motion_1.domAnimation },
220
220
  react_1.default.createElement("div", { className: className },
221
221
  react_1.default.createElement("div", { className: styles_module_css_1.default.outer, ref: refOuter, tabIndex: offsetIndex <= 0 ? 0 : offsetIndex - 1, onKeyDown: handleKeyPress, style: {
@@ -237,7 +237,7 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
237
237
  (hasSelect && classImageSelect) +
238
238
  ' ' +
239
239
  classImageUnique +
240
- index, src: image.src, alt: image.alt, role: 'button', draggable: false, loading: 'lazy', animate: {
240
+ index, src: image.src, alt: image.alt, role: 'button', draggable: false, loading: loading, onLoad: () => setIsLoaded(true), animate: {
241
241
  y: hasSelect
242
242
  ? vertical
243
243
  ? (average - index) * height +
@@ -281,7 +281,7 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
281
281
  opacity: hasSelect ? initial === null || initial === void 0 ? void 0 : initial.selectOpacity : initial === null || initial === void 0 ? void 0 : initial.opacity
282
282
  }, transition: transition, onClick: () => {
283
283
  setSelect(index);
284
- hasSelect && pickScale && !isDragging && setHasPick(true);
284
+ hasSelect && pickScale && !hasMove && setHasPick(true);
285
285
  }, style: {
286
286
  zIndex: hasSelect ? frontImage : zIndex,
287
287
  width: width + 'px',
@@ -289,8 +289,8 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
289
289
  margin: vertical
290
290
  ? margin + 'px' + ' 0'
291
291
  : '0 ' + margin + 'px',
292
- filter: isLoaded ? 'blur(0)' : `blur(${fadeRange}px)`,
293
- transition: `filter ${transTime}s ease-in-out`
292
+ filter: isLoaded ? 'blur(0)' : `blur(${initialFadeRange}px)`,
293
+ transition: `filter ${initialTransTime}s ease-in-out`
294
294
  } }));
295
295
  })),
296
296
  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.2",
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",