@cuemath/leap 3.0.3 → 3.0.4-hg1
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,19 +1,25 @@
|
|
1
1
|
import { jsx as E } from "react/jsx-runtime";
|
2
2
|
import g from "lottie-web";
|
3
|
-
import { memo as y, forwardRef as
|
4
|
-
import
|
5
|
-
import { fetchLottie as
|
6
|
-
const
|
3
|
+
import { memo as y, forwardRef as b, useRef as m, useMemo as A, useImperativeHandle as I, useEffect as $ } from "react";
|
4
|
+
import x from "../layout/flex-view.js";
|
5
|
+
import { fetchLottie as O } from "./helper.js";
|
6
|
+
const S = b((p, v) => {
|
7
7
|
const {
|
8
|
-
src:
|
8
|
+
src: l,
|
9
9
|
width: L = "100%",
|
10
10
|
height: h = "100%",
|
11
|
-
settings:
|
11
|
+
settings: o,
|
12
12
|
eventListener: i,
|
13
|
-
onRender:
|
14
|
-
animateOnIntersect:
|
15
|
-
} = p,
|
16
|
-
|
13
|
+
onRender: c,
|
14
|
+
animateOnIntersect: s
|
15
|
+
} = p, a = m(null), e = m(null), u = m(null), w = A(
|
16
|
+
() => ({
|
17
|
+
...o,
|
18
|
+
renderer: window.ReactNativeWebView ? "svg" : (o == null ? void 0 : o.renderer) ?? "svg"
|
19
|
+
}),
|
20
|
+
[o]
|
21
|
+
);
|
22
|
+
return I(
|
17
23
|
v,
|
18
24
|
() => ({
|
19
25
|
playSegments: (t, r) => {
|
@@ -38,31 +44,30 @@ const x = w((p, v) => {
|
|
38
44
|
}
|
39
45
|
}),
|
40
46
|
[]
|
41
|
-
),
|
47
|
+
), $(() => ((async () => {
|
42
48
|
try {
|
43
|
-
const r = await
|
44
|
-
|
45
|
-
container:
|
49
|
+
const r = await O(l);
|
50
|
+
a.current && (e.current = g.loadAnimation({
|
51
|
+
container: a.current,
|
46
52
|
animationData: r,
|
47
|
-
renderer: "svg",
|
48
53
|
loop: !0,
|
49
54
|
autoplay: !0,
|
50
|
-
...
|
51
|
-
}),
|
55
|
+
...w
|
56
|
+
}), s && (u.current = new IntersectionObserver(
|
52
57
|
([n]) => {
|
53
58
|
var f, d;
|
54
59
|
n && n.isIntersecting ? (f = e.current) == null || f.play() : (d = e.current) == null || d.pause();
|
55
60
|
},
|
56
61
|
{ threshold: 0 }
|
57
|
-
),
|
62
|
+
), a.current && u.current.observe(a.current)), c == null || c(), i && e.current.addEventListener(i.name, i.callback));
|
58
63
|
} catch (r) {
|
59
64
|
throw Error(`Error loading Lottie animation: ${r}`);
|
60
65
|
}
|
61
66
|
})(), () => {
|
62
67
|
var r;
|
63
|
-
e.current && (i && e.current.removeEventListener(i.name, i.callback),
|
64
|
-
}), [
|
65
|
-
}), F = y(
|
68
|
+
e.current && (i && e.current.removeEventListener(i.name, i.callback), s && ((r = u.current) == null || r.disconnect()), e.current.destroy());
|
69
|
+
}), [l, i, c, s, o]), /* @__PURE__ */ E(x, { ref: a, $width: L, $height: h });
|
70
|
+
}), F = y(S);
|
66
71
|
export {
|
67
72
|
F as default
|
68
73
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lottie-animation.js","sources":["../../../../src/features/ui/lottie-animation/lottie-animation.tsx"],"sourcesContent":["import type { ILottieAnimationProps, ILottieAnimationRef } from './types';\nimport type { AnimationEventName, AnimationItem, AnimationSegment } from 'lottie-web';\n\nimport lottie from 'lottie-web';\nimport { forwardRef, memo, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport FlexView from '../layout/flex-view';\nimport { fetchLottie } from './helper';\n\nconst LottieAnimation = forwardRef<ILottieAnimationRef, ILottieAnimationProps>((props, ref) => {\n const {\n src,\n width = '100%',\n height = '100%',\n settings,\n eventListener,\n onRender,\n animateOnIntersect,\n } = props;\n\n const container = useRef<HTMLDivElement>(null);\n const animationInstance = useRef<AnimationItem | null>(null);\n const intersectionObserver = useRef<IntersectionObserver | null>(null);\n\n useImperativeHandle(\n ref,\n () => ({\n playSegments: (segments: AnimationSegment, forceFlag?: boolean) =>\n animationInstance.current?.playSegments(segments, forceFlag),\n addEventListener: (eventName: string, callback: () => void) =>\n animationInstance.current?.addEventListener(eventName as AnimationEventName, callback),\n removeEventListener: (eventName: string, callback: () => void) =>\n animationInstance.current?.removeEventListener(eventName as AnimationEventName, callback),\n play: () => animationInstance.current?.play(),\n stop: () => animationInstance.current?.stop(),\n }),\n [],\n );\n\n useEffect(() => {\n const loadAnimation = async () => {\n try {\n const animationData = await fetchLottie(src);\n\n if (container.current) {\n animationInstance.current = lottie.loadAnimation({\n container: container.current,\n animationData,\n
|
1
|
+
{"version":3,"file":"lottie-animation.js","sources":["../../../../src/features/ui/lottie-animation/lottie-animation.tsx"],"sourcesContent":["import type { ILottieAnimationProps, ILottieAnimationRef } from './types';\nimport type { AnimationEventName, AnimationItem, AnimationSegment, RendererType } from 'lottie-web';\n\nimport lottie from 'lottie-web';\nimport { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\n\nimport FlexView from '../layout/flex-view';\nimport { fetchLottie } from './helper';\n\nconst LottieAnimation = forwardRef<ILottieAnimationRef, ILottieAnimationProps>((props, ref) => {\n const {\n src,\n width = '100%',\n height = '100%',\n settings,\n eventListener,\n onRender,\n animateOnIntersect,\n } = props;\n\n const container = useRef<HTMLDivElement>(null);\n const animationInstance = useRef<AnimationItem | null>(null);\n const intersectionObserver = useRef<IntersectionObserver | null>(null);\n const newSettings = useMemo(\n () => ({\n ...settings,\n renderer: (window.ReactNativeWebView ? 'svg' : settings?.renderer ?? 'svg') as RendererType,\n }),\n [settings],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n playSegments: (segments: AnimationSegment, forceFlag?: boolean) =>\n animationInstance.current?.playSegments(segments, forceFlag),\n addEventListener: (eventName: string, callback: () => void) =>\n animationInstance.current?.addEventListener(eventName as AnimationEventName, callback),\n removeEventListener: (eventName: string, callback: () => void) =>\n animationInstance.current?.removeEventListener(eventName as AnimationEventName, callback),\n play: () => animationInstance.current?.play(),\n stop: () => animationInstance.current?.stop(),\n }),\n [],\n );\n\n useEffect(() => {\n const loadAnimation = async () => {\n try {\n const animationData = await fetchLottie(src);\n\n if (container.current) {\n animationInstance.current = lottie.loadAnimation({\n container: container.current,\n animationData,\n loop: true,\n autoplay: true,\n ...newSettings,\n });\n\n if (animateOnIntersect) {\n intersectionObserver.current = new IntersectionObserver(\n ([entry]) => {\n if (entry && entry.isIntersecting) {\n animationInstance.current?.play();\n } else {\n animationInstance.current?.pause();\n }\n },\n { threshold: 0 },\n );\n\n if (container.current) {\n intersectionObserver.current.observe(container.current);\n }\n }\n\n onRender?.();\n if (eventListener) {\n animationInstance.current.addEventListener(eventListener.name, eventListener.callback);\n }\n }\n } catch (error) {\n throw Error(`Error loading Lottie animation: ${error}`);\n }\n };\n\n loadAnimation();\n\n return () => {\n if (animationInstance.current) {\n if (eventListener) {\n animationInstance.current.removeEventListener(eventListener.name, eventListener.callback);\n }\n\n if (animateOnIntersect) {\n intersectionObserver.current?.disconnect();\n }\n animationInstance.current.destroy();\n }\n };\n }, [src, eventListener, onRender, animateOnIntersect, settings]);\n\n return <FlexView ref={container} $width={width} $height={height} />;\n});\n\nexport default memo(LottieAnimation);\n"],"names":["LottieAnimation","forwardRef","props","ref","src","width","height","settings","eventListener","onRender","animateOnIntersect","container","useRef","animationInstance","intersectionObserver","newSettings","useMemo","useImperativeHandle","segments","forceFlag","_a","eventName","callback","useEffect","animationData","fetchLottie","lottie","entry","_b","error","FlexView","LottieAnimation$1","memo"],"mappings":";;;;;AASA,MAAMA,IAAkBC,EAAuD,CAACC,GAAOC,MAAQ;AACvF,QAAA;AAAA,IACJ,KAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,QAAAC,IAAS;AAAA,IACT,UAAAC;AAAA,IACA,eAAAC;AAAA,IACA,UAAAC;AAAA,IACA,oBAAAC;AAAA,EACE,IAAAR,GAEES,IAAYC,EAAuB,IAAI,GACvCC,IAAoBD,EAA6B,IAAI,GACrDE,IAAuBF,EAAoC,IA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W,EAAE;AAAA,MAAA,GAGbjB,EAAU,WACSG,EAAA,QAAQ,QAAQH,EAAU,OAAO,IAI/CF,KAAA,QAAAA,KACPD,KACFK,EAAkB,QAAQ,iBAAiBL,EAAc,MAAMA,EAAc,QAAQ;AAAA,aAGlFqB,GAAO;AACR,YAAA,MAAM,mCAAmCA,CAAK,EAAE;AAAA,IACxD;AAAA,EAAA,MAKK,MAAM;;AACX,IAAIhB,EAAkB,YAChBL,KACFK,EAAkB,QAAQ,oBAAoBL,EAAc,MAAMA,EAAc,QAAQ,GAGtFE,OACFU,IAAAN,EAAqB,YAArB,QAAAM,EAA8B,eAEhCP,EAAkB,QAAQ;EAC5B,IAED,CAACT,GAAKI,GAAeC,GAAUC,GAAoBH,CAAQ,CAAC,qBAEvDuB,GAAS,EAAA,KAAKnB,GAAW,QAAQN,GAAO,SAASC,EAAQ,CAAA;AACnE,CAAC,GAEcyB,IAAAC,EAAKhC,CAAe;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cuemath/leap",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.4-hg1",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -93,6 +93,5 @@
|
|
93
93
|
"vite-plugin-dts": "3.6.4",
|
94
94
|
"vite-plugin-svgr": "3.2.0",
|
95
95
|
"vite-tsconfig-paths": "^4.2.2"
|
96
|
-
}
|
97
|
-
"packageManager": "yarn@4.4.1"
|
96
|
+
}
|
98
97
|
}
|