@remotion/lottie 4.0.344 → 4.0.345

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.
@@ -26,13 +26,14 @@ const Lottie = ({ animationData, className, direction, loop, playbackRate, style
26
26
  const containerRef = (0, react_1.useRef)(null);
27
27
  const onAnimationLoadedRef = (0, react_1.useRef)(onAnimationLoaded);
28
28
  onAnimationLoadedRef.current = onAnimationLoaded;
29
- const [handle] = (0, react_1.useState)(() => (0, remotion_1.delayRender)('Waiting for Lottie animation to load'));
29
+ const { delayRender, continueRender } = (0, remotion_1.useDelayRender)();
30
+ const [handle] = (0, react_1.useState)(() => delayRender('Waiting for Lottie animation to load'));
30
31
  // If component unmounts, continue the render
31
32
  (0, react_1.useEffect)(() => {
32
33
  return () => {
33
- (0, remotion_1.continueRender)(handle);
34
+ continueRender(handle);
34
35
  };
35
- }, [handle]);
36
+ }, [handle, continueRender]);
36
37
  const frame = (0, remotion_1.useCurrentFrame)();
37
38
  currentFrameRef.current = frame;
38
39
  (0, react_1.useEffect)(() => {
@@ -66,7 +67,7 @@ const Lottie = ({ animationData, className, direction, loop, playbackRate, style
66
67
  (_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.goToAndStop(Math.max(0, frameToSet - 1), true);
67
68
  (_b = animationRef.current) === null || _b === void 0 ? void 0 : _b.goToAndStop(frameToSet, true);
68
69
  }
69
- (0, remotion_1.continueRender)(handle);
70
+ continueRender(handle);
70
71
  };
71
72
  animation.addEventListener('DOMLoaded', onComplete);
72
73
  (_a = onAnimationLoadedRef.current) === null || _a === void 0 ? void 0 : _a.call(onAnimationLoadedRef, animation);
@@ -83,6 +84,7 @@ const Lottie = ({ animationData, className, direction, loop, playbackRate, style
83
84
  playbackRate,
84
85
  preserveAspectRatio,
85
86
  renderer,
87
+ continueRender,
86
88
  ]);
87
89
  (0, react_1.useEffect)(() => {
88
90
  if (animationRef.current && direction) {
@@ -113,14 +115,14 @@ const Lottie = ({ animationData, className, direction, loop, playbackRate, style
113
115
  if (currentHref && currentHref === img.href.baseVal) {
114
116
  return;
115
117
  }
116
- const imgHandle = (0, remotion_1.delayRender)(`Waiting for lottie image with src="${img.href.baseVal}" to load`);
118
+ const imgHandle = delayRender(`Waiting for lottie image with src="${img.href.baseVal}" to load`);
117
119
  // https://stackoverflow.com/a/46839799
118
120
  img.addEventListener('load', () => {
119
- (0, remotion_1.continueRender)(imgHandle);
121
+ continueRender(imgHandle);
120
122
  }, { once: true });
121
123
  img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', img.href.baseVal);
122
124
  });
123
- }, [direction, frame, loop, playbackRate]);
125
+ }, [direction, frame, loop, playbackRate, delayRender, continueRender]);
124
126
  return (0, jsx_runtime_1.jsx)("div", { ref: containerRef, className: className, style: style });
125
127
  };
126
128
  exports.Lottie = Lottie;
@@ -18,7 +18,7 @@ var getLottieMetadata = (animationData) => {
18
18
  // src/Lottie.tsx
19
19
  import lottie from "lottie-web";
20
20
  import { useEffect, useRef, useState } from "react";
21
- import { continueRender, delayRender, useCurrentFrame } from "remotion";
21
+ import { useCurrentFrame, useDelayRender } from "remotion";
22
22
 
23
23
  // src/utils.ts
24
24
  var getLottieFrame = ({
@@ -84,12 +84,13 @@ var Lottie = ({
84
84
  const containerRef = useRef(null);
85
85
  const onAnimationLoadedRef = useRef(onAnimationLoaded);
86
86
  onAnimationLoadedRef.current = onAnimationLoaded;
87
+ const { delayRender, continueRender } = useDelayRender();
87
88
  const [handle] = useState(() => delayRender("Waiting for Lottie animation to load"));
88
89
  useEffect(() => {
89
90
  return () => {
90
91
  continueRender(handle);
91
92
  };
92
- }, [handle]);
93
+ }, [handle, continueRender]);
93
94
  const frame = useCurrentFrame();
94
95
  currentFrameRef.current = frame;
95
96
  useEffect(() => {
@@ -134,7 +135,8 @@ var Lottie = ({
134
135
  loop,
135
136
  playbackRate,
136
137
  preserveAspectRatio,
137
- renderer
138
+ renderer,
139
+ continueRender
138
140
  ]);
139
141
  useEffect(() => {
140
142
  if (animationRef.current && direction) {
@@ -170,7 +172,7 @@ var Lottie = ({
170
172
  }, { once: true });
171
173
  img.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", img.href.baseVal);
172
174
  });
173
- }, [direction, frame, loop, playbackRate]);
175
+ }, [direction, frame, loop, playbackRate, delayRender, continueRender]);
174
176
  return /* @__PURE__ */ jsx("div", {
175
177
  ref: containerRef,
176
178
  className,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/lottie"
4
4
  },
5
5
  "name": "@remotion/lottie",
6
- "version": "4.0.344",
6
+ "version": "4.0.345",
7
7
  "description": "Include Lottie animations in Remotion",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "license": "SEE LICENSE IN LICENSE.md",
21
21
  "dependencies": {
22
- "remotion": "4.0.344"
22
+ "remotion": "4.0.345"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "lottie-web": "^5",
@@ -40,7 +40,7 @@
40
40
  "react-dom": "19.0.0",
41
41
  "lottie-web": "5.13.0",
42
42
  "eslint": "9.19.0",
43
- "@remotion/eslint-config-internal": "4.0.344"
43
+ "@remotion/eslint-config-internal": "4.0.345"
44
44
  },
45
45
  "keywords": [
46
46
  "remotion",