react-magic-card 0.1.19 → 0.1.21

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
@@ -73,6 +73,7 @@ function MyComponent() {
73
73
  | delay | delay of the animation firing interval |
74
74
  | offsetIndex | add an offset to the index of the components and images |
75
75
  | reverseIndex | reverse index order the default true |
76
+ | loading | loading option of the eager or lazy the default auto |
76
77
  | className | className of the component |
77
78
  | classImages | className of the images |
78
79
  | 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, height, width, dynamic, clockwise, radius, start, delay, controller, offsetIndex, reverseIndex, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickProperty, pickTransition }: MagicCircleProps) => React.JSX.Element;
3
+ export declare const MagicCircle: ({ images, height, width, dynamic, clockwise, radius, start, delay, controller, offsetIndex, reverseIndex, loading, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, 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, height, width, dynamic = true, clockwise = true, radius, start, delay = 100, controller, offsetIndex = 0, reverseIndex = true, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickProperty, pickTransition }) => {
34
+ const MagicCircle = ({ images, height, width, dynamic = true, clockwise = true, radius, start, delay = 100, controller, offsetIndex = 0, reverseIndex = true, loading, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickProperty, pickTransition }) => {
35
35
  const [count, setCount] = (0, react_1.useState)(0);
36
36
  const [touchStartY, setTouchStartY] = (0, react_1.useState)(0);
37
37
  const [touchStartX, setTouchStartX] = (0, react_1.useState)(0);
@@ -171,7 +171,7 @@ const MagicCircle = ({ images, height, width, dynamic = true, clockwise = true,
171
171
  const zIndex = reverseIndex
172
172
  ? offsetIndex + images.length - 1 - index
173
173
  : offsetIndex + index;
174
- return (react_1.default.createElement(framer_motion_1.m.img, { key: zIndex, animate: {
174
+ return (react_1.default.createElement(framer_motion_1.m.img, { key: zIndex, loading: loading, animate: {
175
175
  rotate: -count,
176
176
  scale: hasSelect ? animate === null || animate === void 0 ? void 0 : animate.selectScale : animate === null || animate === void 0 ? void 0 : animate.scale,
177
177
  rotateY: hasSelect
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import type { MagicStraightProps } from '../types';
3
- export declare const MagicStraight: ({ images, height, width, vertical, margin, selectOffsetX, selectOffsetY, start, controller, delay, offsetIndex, reverseIndex, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickProperty, pickTransition }: MagicStraightProps) => React.JSX.Element;
3
+ export declare const MagicStraight: ({ images, height, width, vertical, margin, selectOffsetX, selectOffsetY, start, controller, delay, offsetIndex, reverseIndex, loading, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, 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, height, width, vertical = true, margin = 0, selectOffsetX = 0, selectOffsetY = 0, start, controller, delay = 20, offsetIndex = 0, reverseIndex = true, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickProperty, pickTransition }) => {
34
+ const MagicStraight = ({ images, height, width, vertical = true, margin = 0, selectOffsetX = 0, selectOffsetY = 0, start, controller, delay = 20, offsetIndex = 0, reverseIndex = true, loading, className, classImages, classImageSelect, classImageUnique, animate, initial, transition, pickProperty, pickTransition }) => {
35
35
  const [touchStartY, setTouchStartY] = (0, react_1.useState)(0);
36
36
  const [touchStartX, setTouchStartX] = (0, react_1.useState)(0);
37
37
  const [hasShift, setHasShift] = (0, react_1.useState)(false);
@@ -177,21 +177,18 @@ const MagicStraight = ({ images, height, width, vertical = true, margin = 0, sel
177
177
  react_1.default.createElement("div", { ref: div1Ref, tabIndex: offsetIndex <= 0 ? 0 : offsetIndex - 1, onKeyDown: handleKeyPress, className: className + ' ' + styles_module_css_1.default.outer, style: {
178
178
  zIndex: offsetIndex - 1,
179
179
  width: !vertical
180
- ? images.length * (width + margin * 2) + 'px'
181
- : 'fit-content',
180
+ ? images.length * (width + margin * 2) + controller + 'px'
181
+ : width + controller,
182
182
  height: vertical
183
- ? images.length * (height + margin * 2) + 'px'
184
- : 'fit-content',
185
- padding: vertical
186
- ? controller + 'px ' + controller / 2 + 'px'
187
- : controller / 2 + 'px ' + controller + 'px',
183
+ ? images.length * (height + margin * 2) + controller + 'px'
184
+ : height + controller,
188
185
  flexDirection: vertical ? 'column' : 'row'
189
186
  } }, images.map((image, index) => {
190
187
  const hasSelect = images[select] == images[index];
191
188
  const zIndex = reverseIndex
192
189
  ? offsetIndex + images.length - 1 - index
193
190
  : offsetIndex + index;
194
- return (react_1.default.createElement(framer_motion_1.m.img, { key: zIndex, animate: {
191
+ return (react_1.default.createElement(framer_motion_1.m.img, { key: zIndex, loading: loading, animate: {
195
192
  y: hasSelect
196
193
  ? vertical
197
194
  ? (average - index) * height +
package/dist/types.d.ts CHANGED
@@ -47,6 +47,7 @@ type MagicProperty = {
47
47
  delay: number;
48
48
  offsetIndex?: number;
49
49
  reverseIndex?: boolean;
50
+ loading?: 'eager' | 'lazy';
50
51
  className?: string;
51
52
  classImages?: string;
52
53
  classImageSelect?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-magic-card",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "image gallery components with framer motion",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",