infinity-forge 7.7.9 → 7.8.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.
@@ -1,9 +1,23 @@
1
1
  import { types } from './type-animation.js';
2
+ interface Offset {
3
+ x?: number;
4
+ y?: number;
5
+ }
2
6
  interface IElementAnimationProps {
3
- duration?: number;
4
- type: keyof typeof types;
7
+ type?: keyof typeof types;
5
8
  children: React.ReactNode;
6
- element: keyof JSX.IntrinsicElements;
9
+ element?: keyof JSX.IntrinsicElements;
10
+ duration?: number;
11
+ delay?: number;
12
+ easing?: string;
13
+ offset?: Offset;
14
+ customAnimate?: Partial<{
15
+ opacity: number;
16
+ x: number;
17
+ y: number;
18
+ [key: string]: any;
19
+ }>;
20
+ once?: boolean;
7
21
  }
8
- export declare function Animation({ children, duration, type, element }: IElementAnimationProps): import("react/jsx-runtime").JSX.Element;
22
+ export declare function Animation({ children, type, element, duration, delay, easing, offset, customAnimate, once, }: IElementAnimationProps): import("react/jsx-runtime").JSX.Element;
9
23
  export {};
@@ -17,16 +17,20 @@ var react_1 = require("react");
17
17
  var react_2 = require("motion/react");
18
18
  var type_animation_1 = require("./type-animation.js");
19
19
  function Animation(_a) {
20
- var children = _a.children, duration = _a.duration, type = _a.type, _b = _a.element, element = _b === void 0 ? 'div' : _b;
20
+ var children = _a.children, type = _a.type, _b = _a.element, element = _b === void 0 ? 'div' : _b, _c = _a.duration, duration = _c === void 0 ? 0.7 : _c, _d = _a.delay, delay = _d === void 0 ? 0 : _d, _e = _a.easing, easing = _e === void 0 ? 'easeInOut' : _e, _f = _a.offset, offset = _f === void 0 ? {} : _f, _g = _a.customAnimate, customAnimate = _g === void 0 ? {} : _g, _h = _a.once, once = _h === void 0 ? false : _h;
21
21
  var ref = (0, react_1.useRef)(null);
22
22
  var isInView = (0, react_2.useInView)(ref);
23
23
  var Element = react_2.motion[element];
24
- var defaultAnimate = {
25
- opacity: 1,
26
- y: 0,
27
- x: 0,
28
- };
29
- var animate = isInView ? defaultAnimate : __assign({ opacity: 0 }, type_animation_1.types[type]);
30
- return ((0, jsx_runtime_1.jsx)(Element, { ref: ref, animate: animate, initial: type_animation_1.types[type], transition: { duration: duration || 0.7, ease: 'easeInOut' }, children: children }));
24
+ var _j = (0, react_1.useState)(false), hasAnimated = _j[0], setHasAnimated = _j[1];
25
+ (0, react_1.useEffect)(function () {
26
+ if (isInView && !hasAnimated) {
27
+ setHasAnimated(true);
28
+ }
29
+ }, [isInView, hasAnimated]);
30
+ var initialAnimation = __assign(__assign({}, type_animation_1.types[type]), offset);
31
+ var shouldAnimate = once ? hasAnimated : isInView;
32
+ var animate = shouldAnimate
33
+ ? __assign({ opacity: 1, x: 0, y: 0 }, customAnimate) : initialAnimation;
34
+ return ((0, jsx_runtime_1.jsx)(Element, { ref: ref, initial: initialAnimation, animate: animate, transition: { duration: duration, delay: delay, ease: easing }, children: children }));
31
35
  }
32
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/components/animation/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAaA,8BAwBC;;AArCD,+BAA8B;AAE9B,sCAAgD;AAEhD,mDAAwC;AASxC,SAAgB,SAAS,CAAC,EAAqE;QAAnE,QAAQ,cAAA,EAAE,QAAQ,cAAA,EAAE,IAAI,UAAA,EAAE,eAAe,EAAf,OAAO,mBAAG,KAAK,KAAA;IACnE,IAAM,GAAG,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAA;IACxB,IAAM,QAAQ,GAAG,IAAA,iBAAS,EAAC,GAAG,CAAC,CAAA;IAE/B,IAAM,OAAO,GAAG,cAAM,CAAC,OAAO,CAAsB,CAAA;IAEpD,IAAM,cAAc,GAAG;QACrB,OAAO,EAAE,CAAC;QACV,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;KACL,CAAA;IAED,IAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAA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AAC,IAAI,CAAC,CAAA;QACtB,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAA;IAE3B,IAAM,gBAAgB,yBACjB,sBAAK,CAAC,IAAI,CAAC,GACX,MAAM,CACV,CAAA;IAED,IAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAA;IACnD,IAAM,OAAO,GAAG,aAAa;QAC3B,CAAC,YAAG,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAK,aAAa,EAC5C,CAAC,CAAC,gBAAgB,CAAA;IAEpB,OAAO,CACL,uBAAC,OAAO,IACN,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,EAAE,QAAQ,UAAA,EAAE,KAAK,OAAA,EAAE,IAAI,EAAE,MAAM,EAAE,YAE5C,QAAQ,GACD,CACX,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infinity-forge",
3
- "version": "7.7.9",
3
+ "version": "7.8.0",
4
4
  "description": "codie Library",
5
5
  "main": "./dist/index",
6
6
  "module": "./dist/index",