react-magic-card 2.0.7 → 2.0.8

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,25 +13,31 @@ 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',
21
+ src: '/cat.jpeg',
22
+ alt: 'alt'
23
+ },
24
+ {
25
+ src: '/dog.jpeg',
26
+ alt: 'alt'
27
+ },
28
+ {
29
+ src: '/bird.jpeg',
24
30
  alt: 'alt'
25
31
  }
26
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 - 1)}
37
41
  />
38
42
  )
39
43
  }
@@ -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
 
@@ -86,29 +86,31 @@ function MyComponent() {
86
86
  | ------------- | ------------------------------------- |
87
87
  | scale | scaling of the images |
88
88
  | opacity | opacity or transparency of the images |
89
+ | rotate | rotation of the images |
89
90
  | rotateX | X-axis rotation of the images |
90
91
  | rotateY | Y-axis rotation of the images |
91
92
  | rotateZ | Z-axis rotation of the images |
92
93
  | selectScale | scaling of the selected image |
93
94
  | selectOpacity | opacity of the selected image |
95
+ | selectRotate | rotation of the selected image |
94
96
  | selectRotateX | X-axis rotation of the selected image |
95
97
  | selectRotateY | Y-axis rotation of the selected image |
96
98
  | selectRotateZ | Z-axis rotation of the selected image |
97
99
 
98
100
  ## Transition Object
99
101
 
100
- It is Inherits framer motion transition object other than intera.
102
+ It is Inherits framer motion transition object ease and (type: 'spring').
101
103
 
102
- ## PickProperty Object
104
+ ## detailProperty Object
103
105
 
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 |
106
+ | Property | Meaning |
107
+ | ----------- | ----------------------------------------------------- |
108
+ | classDetail | className of the detail image |
109
+ | white | white or black for background the default true |
110
+ | alpha | background transparency of a number between 0 ~ 1 |
111
+ | blur | blur intensity of a number between 1 ~ 20 a preferred |
112
+ | scale | scale of the detail image |
113
+ | rotate | rotation of the images |
112
114
 
113
115
  ## License
114
116
 
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -312,8 +322,8 @@ const CircleRotation = ({ images, start, height, width, radius, controller, offs
312
322
  opacity: hasSelect
313
323
  ? hasDetail
314
324
  ? 0
315
- : animate?.selectOpacity
316
- : animate?.opacity
325
+ : animate?.selectOpacity ?? 1
326
+ : animate?.opacity ?? 1
317
327
  }, initial: {
318
328
  rotate: -count - (initial?.rotate ? initial?.rotate : 0),
319
329
  scale: hasSelect ? initial?.selectScale : initial?.scale,
@@ -329,7 +339,9 @@ const CircleRotation = ({ images, start, height, width, radius, controller, offs
329
339
  opacity: hasSelect
330
340
  ? initial?.selectOpacity
331
341
  : initial?.opacity
332
- }, transition: transition, onPointerDown: () => setSelect(index), onClick: () => hasSelect && detail && !hasMove && setHasDetail(true), style: {
342
+ }, transition: hasSelect && detailTransition
343
+ ? { ...transition, opacity: detailTransition }
344
+ : transition, onPointerDown: () => setSelect(index), onClick: () => hasSelect && detail && !hasMove && setHasDetail(true), style: {
333
345
  zIndex: hasSelect ? frontImage : zIndex,
334
346
  width: width + 'px',
335
347
  height: height + 'px',
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -343,8 +353,8 @@ const StraightInfinity = ({ images, start, height, width, vertical = false, marg
343
353
  : hasSelect
344
354
  ? hasDetail
345
355
  ? 0
346
- : animate?.selectOpacity
347
- : animate?.opacity
356
+ : animate?.selectOpacity ?? 1
357
+ : animate?.opacity ?? 1
348
358
  }, initial: {
349
359
  scale: hasSelect ? initial?.selectScale : initial?.scale,
350
360
  rotate: hasSelect ? initial?.selectRotate : initial?.rotate,
@@ -358,7 +368,9 @@ const StraightInfinity = ({ images, start, height, width, vertical = false, marg
358
368
  ? initial?.selectRotateZ
359
369
  : initial?.rotateZ,
360
370
  opacity: hasSelect ? initial?.selectOpacity : initial?.opacity
361
- }, transition: transition, onClick: () => {
371
+ }, transition: hasSelect && detailTransition
372
+ ? { ...transition, opacity: detailTransition }
373
+ : transition, onClick: () => {
362
374
  hasSelect && detail && !hasMove && setHasDetail(true);
363
375
  if (!hasDelayed)
364
376
  return;
@@ -8,17 +8,16 @@ const react_1 = __importDefault(require("react"));
8
8
  const framer_motion_1 = require("framer-motion");
9
9
  const styles_module_css_1 = __importDefault(require("./styles.module.css"));
10
10
  const DetailImage = ({ onClick, classDetail, hasDetail, detailRef, detailKey, src, alt, width, height, zIndex, white = true, alpha = 0.3, blur = 3, scale = 2.5, rotate = 0, transition }) => {
11
- const backdropFilter = hasDetail ? `blur(${blur}px)` : undefined;
12
- const background = hasDetail
13
- ? white
14
- ? `rgba(255, 255, 255, ${alpha})`
15
- : `rgba(0, 0, 0, ${alpha})`
16
- : undefined;
11
+ const backdropFilter = `blur(${hasDetail ? blur : 0}px)`;
12
+ const color = white ? '255, 255, 255' : '0, 0, 0';
13
+ const backgroundColor = `rgba(${color}, ${hasDetail ? alpha : 0})`;
17
14
  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: {
18
15
  zIndex: zIndex,
19
- opacity: hasDetail ? 1 : 0,
16
+ backdropFilter: backdropFilter,
17
+ WebkitBackdropFilter: backdropFilter,
18
+ backgroundColor: backgroundColor,
20
19
  pointerEvents: hasDetail ? 'auto' : 'none'
21
- }, style: { backdropFilter: backdropFilter, background: background }, transition: transition },
20
+ }, initial: false, transition: transition },
22
21
  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: {
23
22
  zIndex: zIndex + 1,
24
23
  scale: scale,
package/package.json CHANGED
@@ -1,14 +1,7 @@
1
1
  {
2
2
  "name": "react-magic-card",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "React Component library for images gallery using the framer motion animation.",
5
- "main": "dist/index.js",
6
- "typings": "dist/index.d.ts",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/su-pull/react-magic-card",
10
- "directory": "react-magic-card/src"
11
- },
12
5
  "keywords": [
13
6
  "react",
14
7
  "component",
@@ -19,12 +12,30 @@
19
12
  "infinity"
20
13
  ],
21
14
  "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/su-pull/react-magic-card",
18
+ "directory": "react-magic-card/src"
19
+ },
20
+ "main": "dist/index.js",
21
+ "typings": "dist/index.d.ts",
22
+ "files": [
23
+ "dist/"
24
+ ],
25
+ "scripts": {
26
+ "build": "npx tsc && npm run copy-css",
27
+ "copy-css": "npm run copy-css1 && npm run copy-css2 && npm run copy-css3",
28
+ "copy-css1": "cp src/CircleRotation/styles.module.css dist/CircleRotation/styles.module.css",
29
+ "copy-css2": "cp src/StraightInfinity/styles.module.css dist/StraightInfinity/styles.module.css",
30
+ "copy-css3": "cp src/common/DetailImage/styles.module.css dist/common/DetailImage/styles.module.css",
31
+ "test": "test"
32
+ },
22
33
  "peerDependencies": {
23
34
  "framer-motion": "^11.3.21"
24
35
  },
25
36
  "devDependencies": {
26
- "typescript": "^5.1.3",
27
- "@types/react": "^18.2.12",
28
- "@types/css-modules": "^1.0.2"
37
+ "@types/css-modules": "^1.0.5",
38
+ "@types/react": "^18.3.31",
39
+ "typescript": "^6.0.3"
29
40
  }
30
41
  }