react-magic-card 1.0.4 → 1.1.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
@@ -50,7 +50,9 @@ function MyComponent() {
50
50
  | controller (required) | controller size is add to the size of the component |
51
51
  | delay | delay of the animation firing interval |
52
52
  | offsetIndex | add an offset to the index of the components and images |
53
- | reverseIndex | reverse index order the default true |
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
56
  | className | className of the component |
55
57
  | classImages | className of the images |
56
58
  | 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, loading, 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, fadeRange, transTime, 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, loading, 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, fadeRange = 4, transTime = 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);
@@ -267,13 +267,18 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
267
267
  e.key === 'Enter' && setHasPick(true);
268
268
  e.key === 'Escape' && setHasPick(false);
269
269
  };
270
+ // has after Lazy loading fade transition.
271
+ const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
272
+ (0, react_1.useEffect)(() => {
273
+ setIsLoaded(true);
274
+ }, []);
270
275
  return (react_1.default.createElement(framer_motion_1.LazyMotion, { features: framer_motion_1.domAnimation },
271
276
  react_1.default.createElement("div", { className: className },
272
277
  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: {
273
278
  zIndex: offsetIndex - 1,
274
279
  width: radius * 2 + controller + 'px',
275
280
  height: radius * 2 + controller + 'px'
276
- }, animate: { rotate: count }, transition: { duration: transition === null || transition === void 0 ? void 0 : transition.duration } },
281
+ }, animate: { rotate: count }, transition: transition },
277
282
  react_1.default.createElement("div", { className: styles_module_css_1.default.inner, style: { width: radius * 2 + 'px', height: radius * 2 + 'px' } }, images.map((image, index) => {
278
283
  const hasSelect = images[select] == images[index];
279
284
  const zIndex = reverseIndex
@@ -284,7 +289,7 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
284
289
  (hasSelect && classImageSelect) +
285
290
  ' ' +
286
291
  classImageUnique +
287
- zIndex, src: image.src, alt: image.alt, role: "button", draggable: false, loading: loading, animate: {
292
+ zIndex, role: 'button', src: image.src, alt: image.alt, draggable: false, loading: 'lazy', animate: {
288
293
  rotate: -count,
289
294
  scale: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectScale : animate === null || animate === void 0 ? void 0 : animate.scale,
290
295
  rotateY: hasSelect
@@ -316,7 +321,7 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
316
321
  opacity: hasSelect
317
322
  ? initial === null || initial === void 0 ? void 0 : initial.selectOpacity
318
323
  : initial === null || initial === void 0 ? void 0 : initial.opacity
319
- }, transition: transition, onMouseDown: () => setSelect(index), onClick: () => hasSelect && pickScale && !hasMove && setHasPick(true), style: {
324
+ }, transition: transition, onMouseDown: () => setSelect(index), onPointerDown: () => setSelect(index), onClick: () => hasSelect && pickScale && !hasMove && setHasPick(true), style: {
320
325
  zIndex: hasSelect ? frontImage : zIndex,
321
326
  width: width + 'px',
322
327
  height: height + 'px',
@@ -327,7 +332,9 @@ const MagicCircle = ({ images, start, height, width, dynamic = true, scrollDirec
327
332
  top: radius * Math.sin(index * angle) +
328
333
  radius -
329
334
  height / 2 +
330
- 'px'
335
+ 'px',
336
+ filter: isLoaded ? 'blur(0)' : `blur(${fadeRange}px)`,
337
+ transition: `filter ${transTime}s ease-in-out`
331
338
  } }));
332
339
  }))),
333
340
  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, loading, 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, fadeRange, transTime, 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, loading, 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, fadeRange = 4, transTime = 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);
@@ -211,6 +211,11 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
211
211
  e.key === 'Enter' && setHasPick(true);
212
212
  e.key === 'Escape' && setHasPick(false);
213
213
  };
214
+ // has after Lazy loading fade transition.
215
+ const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
216
+ (0, react_1.useEffect)(() => {
217
+ setIsLoaded(true);
218
+ }, []);
214
219
  return (react_1.default.createElement(framer_motion_1.LazyMotion, { features: framer_motion_1.domAnimation },
215
220
  react_1.default.createElement("div", { className: className },
216
221
  react_1.default.createElement("div", { className: styles_module_css_1.default.outer, ref: refOuter, tabIndex: offsetIndex <= 0 ? 0 : offsetIndex - 1, onKeyDown: handleKeyPress, style: {
@@ -232,7 +237,7 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
232
237
  (hasSelect && classImageSelect) +
233
238
  ' ' +
234
239
  classImageUnique +
235
- index, src: image.src, alt: image.alt, role: "button", draggable: false, loading: loading, animate: {
240
+ index, src: image.src, alt: image.alt, role: 'button', draggable: false, loading: 'lazy', animate: {
236
241
  y: hasSelect
237
242
  ? vertical
238
243
  ? (average - index) * height +
@@ -281,7 +286,11 @@ const MagicStraight = ({ images, start, height, width, vertical = true, margin =
281
286
  zIndex: hasSelect ? frontImage : zIndex,
282
287
  width: width + 'px',
283
288
  height: height + 'px',
284
- margin: vertical ? margin + 'px' + ' 0' : '0 ' + margin + 'px'
289
+ margin: vertical
290
+ ? margin + 'px' + ' 0'
291
+ : '0 ' + margin + 'px',
292
+ filter: isLoaded ? 'blur(0)' : `blur(${fadeRange}px)`,
293
+ transition: `filter ${transTime}s ease-in-out`
285
294
  } }));
286
295
  })),
287
296
  react_1.default.createElement(PickImage_1.default, { classPick: pickProperty === null || pickProperty === void 0 ? void 0 : pickProperty.classPick, argRef: refPicker, onClick: () => {
package/dist/types.d.ts CHANGED
@@ -47,7 +47,8 @@ type CommonProperty = {
47
47
  delay: number;
48
48
  offsetIndex?: number;
49
49
  reverseIndex?: boolean;
50
- loading?: 'eager' | 'lazy';
50
+ fadeRange: number;
51
+ transTime: number;
51
52
  className?: string;
52
53
  classImages?: string;
53
54
  classImageSelect?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-magic-card",
3
- "version": "1.0.4",
3
+ "version": "1.1.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",