@remotion/lottie 4.0.528 → 4.0.530
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/dist/cjs/Lottie.d.ts +1 -1
- package/dist/cjs/Lottie.js +21 -21
- package/dist/esm/index.mjs +21 -21
- package/package.json +3 -3
package/dist/cjs/Lottie.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LottieProps } from './types';
|
|
2
|
-
export declare const Lottie: ({ from, durationInFrames, trimBefore, freeze, hidden, name, showInTimeline, premountFor, postmountFor, styleWhilePremounted, styleWhilePostmounted, style, ...props }: LottieProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const Lottie: ({ animationData, from, durationInFrames, trimBefore, playbackRate, loop, freeze, hidden, name, showInTimeline, premountFor, postmountFor, styleWhilePremounted, styleWhilePostmounted, style, ...props }: LottieProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/cjs/Lottie.js
CHANGED
|
@@ -15,12 +15,7 @@ const validate_playbackrate_1 = require("./validate-playbackrate");
|
|
|
15
15
|
* @description Part of the @remotion/lottie package.
|
|
16
16
|
* @see [Documentation](https://www.remotion.dev/docs/lottie/lottie)
|
|
17
17
|
*/
|
|
18
|
-
const LottieContent = ({ animationData, className, direction,
|
|
19
|
-
if (typeof animationData !== 'object') {
|
|
20
|
-
throw new Error('animationData should be provided as an object. If you only have the path to the JSON file, load it and pass it as animationData. See https://remotion.dev/docs/lottie/lottie#example for more information.');
|
|
21
|
-
}
|
|
22
|
-
(0, validate_playbackrate_1.validatePlaybackRate)(playbackRate);
|
|
23
|
-
(0, validate_loop_1.validateLoop)(loop);
|
|
18
|
+
const LottieContent = ({ animationData, className, direction, style, onAnimationLoaded, renderer, preserveAspectRatio, assetsPath, }) => {
|
|
24
19
|
const animationRef = (0, react_1.useRef)(null);
|
|
25
20
|
const currentFrameRef = (0, react_1.useRef)(null);
|
|
26
21
|
const containerRef = (0, react_1.useRef)(null);
|
|
@@ -59,9 +54,8 @@ const LottieContent = ({ animationData, className, direction, loop, playbackRate
|
|
|
59
54
|
// We can work around it by seeking twice, initially.
|
|
60
55
|
if (currentFrameRef.current) {
|
|
61
56
|
const frameToSet = (0, utils_1.getLottieFrame)({
|
|
62
|
-
currentFrame: currentFrameRef.current
|
|
57
|
+
currentFrame: currentFrameRef.current,
|
|
63
58
|
direction,
|
|
64
|
-
loop,
|
|
65
59
|
totalFrames: animation.totalFrames,
|
|
66
60
|
});
|
|
67
61
|
(_a = animationRef.current) === null || _a === void 0 ? void 0 : _a.goToAndStop(Math.max(0, frameToSet - 1), true);
|
|
@@ -80,8 +74,6 @@ const LottieContent = ({ animationData, className, direction, loop, playbackRate
|
|
|
80
74
|
assetsPath,
|
|
81
75
|
direction,
|
|
82
76
|
handle,
|
|
83
|
-
loop,
|
|
84
|
-
playbackRate,
|
|
85
77
|
preserveAspectRatio,
|
|
86
78
|
renderer,
|
|
87
79
|
continueRender,
|
|
@@ -91,11 +83,6 @@ const LottieContent = ({ animationData, className, direction, loop, playbackRate
|
|
|
91
83
|
animationRef.current.setDirection(direction === 'backward' ? -1 : 1);
|
|
92
84
|
}
|
|
93
85
|
}, [direction]);
|
|
94
|
-
(0, react_1.useEffect)(() => {
|
|
95
|
-
if (animationRef.current && playbackRate) {
|
|
96
|
-
animationRef.current.setSpeed(playbackRate);
|
|
97
|
-
}
|
|
98
|
-
}, [playbackRate]);
|
|
99
86
|
(0, react_1.useEffect)(() => {
|
|
100
87
|
var _a;
|
|
101
88
|
if (!animationRef.current) {
|
|
@@ -103,9 +90,8 @@ const LottieContent = ({ animationData, className, direction, loop, playbackRate
|
|
|
103
90
|
}
|
|
104
91
|
const { totalFrames } = animationRef.current;
|
|
105
92
|
const frameToSet = (0, utils_1.getLottieFrame)({
|
|
106
|
-
currentFrame: frame
|
|
93
|
+
currentFrame: frame,
|
|
107
94
|
direction,
|
|
108
|
-
loop,
|
|
109
95
|
totalFrames,
|
|
110
96
|
});
|
|
111
97
|
animationRef.current.goToAndStop(frameToSet, true);
|
|
@@ -122,13 +108,27 @@ const LottieContent = ({ animationData, className, direction, loop, playbackRate
|
|
|
122
108
|
}, { once: true });
|
|
123
109
|
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', img.href.baseVal);
|
|
124
110
|
});
|
|
125
|
-
}, [direction, frame,
|
|
111
|
+
}, [direction, frame, delayRender, continueRender]);
|
|
126
112
|
return jsx_runtime_1.jsx("div", { ref: containerRef, className: className, style: style });
|
|
127
113
|
};
|
|
128
|
-
const Lottie = ({ from, durationInFrames, trimBefore, freeze, hidden, name, showInTimeline, premountFor, postmountFor, styleWhilePremounted, styleWhilePostmounted, style, ...props }) => {
|
|
114
|
+
const Lottie = ({ animationData, from, durationInFrames, trimBefore, playbackRate, loop, freeze, hidden, name, showInTimeline, premountFor, postmountFor, styleWhilePremounted, styleWhilePostmounted, style, ...props }) => {
|
|
115
|
+
if (typeof animationData !== 'object' || animationData === null) {
|
|
116
|
+
throw new Error('animationData should be provided as an object. If you only have the path to the JSON file, load it and pass it as animationData. See https://remotion.dev/docs/lottie/lottie#example for more information.');
|
|
117
|
+
}
|
|
118
|
+
(0, validate_playbackrate_1.validatePlaybackRate)(playbackRate);
|
|
119
|
+
(0, validate_loop_1.validateLoop)(loop);
|
|
120
|
+
// Match lottie-web's totalFrames so an implicit loop ends at the asset boundary.
|
|
121
|
+
const sequenceDurationInFrames = loop && durationInFrames === undefined
|
|
122
|
+
? Math.floor(animationData.op -
|
|
123
|
+
(typeof animationData.ip === 'number' ? animationData.ip : 0)) - (trimBefore !== null && trimBefore !== void 0 ? trimBefore : 0)
|
|
124
|
+
: durationInFrames;
|
|
129
125
|
const { effectivePremountFor, effectivePostmountFor, freezeFrame, isPremountingOrPostmounting, premountingActive, postmountingActive, premountingStyle, } = remotion_1.Internals.usePremounting({
|
|
130
126
|
from: from !== null && from !== void 0 ? from : 0,
|
|
131
|
-
durationInFrames:
|
|
127
|
+
durationInFrames: remotion_1.Internals.resolveSequenceDuration({
|
|
128
|
+
durationInFrames: sequenceDurationInFrames,
|
|
129
|
+
playbackRate,
|
|
130
|
+
loop,
|
|
131
|
+
}),
|
|
132
132
|
premountFor: premountFor !== null && premountFor !== void 0 ? premountFor : null,
|
|
133
133
|
postmountFor: postmountFor !== null && postmountFor !== void 0 ? postmountFor : null,
|
|
134
134
|
style: style !== null && style !== void 0 ? style : null,
|
|
@@ -136,6 +136,6 @@ const Lottie = ({ from, durationInFrames, trimBefore, freeze, hidden, name, show
|
|
|
136
136
|
styleWhilePostmounted: styleWhilePostmounted !== null && styleWhilePostmounted !== void 0 ? styleWhilePostmounted : null,
|
|
137
137
|
hideWhilePremounted: 'opacity',
|
|
138
138
|
});
|
|
139
|
-
return (jsx_runtime_1.jsx(remotion_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: jsx_runtime_1.jsx(remotion_1.Sequence, { layout: "none", from: from, durationInFrames:
|
|
139
|
+
return (jsx_runtime_1.jsx(remotion_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: jsx_runtime_1.jsx(remotion_1.Sequence, { layout: "none", from: from, durationInFrames: sequenceDurationInFrames, trimBefore: trimBefore, playbackRate: playbackRate, loop: loop, freeze: freeze, hidden: hidden, name: name !== null && name !== void 0 ? name : '<Lottie>', showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : false, _remotionInternalPremountDisplay: effectivePremountFor || null, _remotionInternalPostmountDisplay: effectivePostmountFor || null, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, children: jsx_runtime_1.jsx(LottieContent, { ...props, animationData: animationData, style: premountingStyle !== null && premountingStyle !== void 0 ? premountingStyle : undefined }) }) }));
|
|
140
140
|
};
|
|
141
141
|
exports.Lottie = Lottie;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -72,19 +72,12 @@ var LottieContent = ({
|
|
|
72
72
|
animationData,
|
|
73
73
|
className,
|
|
74
74
|
direction,
|
|
75
|
-
loop,
|
|
76
|
-
playbackRate,
|
|
77
75
|
style,
|
|
78
76
|
onAnimationLoaded,
|
|
79
77
|
renderer,
|
|
80
78
|
preserveAspectRatio,
|
|
81
79
|
assetsPath
|
|
82
80
|
}) => {
|
|
83
|
-
if (typeof animationData !== "object") {
|
|
84
|
-
throw new Error("animationData should be provided as an object. If you only have the path to the JSON file, load it and pass it as animationData. See https://remotion.dev/docs/lottie/lottie#example for more information.");
|
|
85
|
-
}
|
|
86
|
-
validatePlaybackRate(playbackRate);
|
|
87
|
-
validateLoop(loop);
|
|
88
81
|
const animationRef = useRef(null);
|
|
89
82
|
const currentFrameRef = useRef(null);
|
|
90
83
|
const containerRef = useRef(null);
|
|
@@ -117,9 +110,8 @@ var LottieContent = ({
|
|
|
117
110
|
const onComplete = () => {
|
|
118
111
|
if (currentFrameRef.current) {
|
|
119
112
|
const frameToSet = getLottieFrame({
|
|
120
|
-
currentFrame: currentFrameRef.current
|
|
113
|
+
currentFrame: currentFrameRef.current,
|
|
121
114
|
direction,
|
|
122
|
-
loop,
|
|
123
115
|
totalFrames: animation.totalFrames
|
|
124
116
|
});
|
|
125
117
|
animationRef.current?.goToAndStop(Math.max(0, frameToSet - 1), true);
|
|
@@ -138,8 +130,6 @@ var LottieContent = ({
|
|
|
138
130
|
assetsPath,
|
|
139
131
|
direction,
|
|
140
132
|
handle,
|
|
141
|
-
loop,
|
|
142
|
-
playbackRate,
|
|
143
133
|
preserveAspectRatio,
|
|
144
134
|
renderer,
|
|
145
135
|
continueRender
|
|
@@ -149,20 +139,14 @@ var LottieContent = ({
|
|
|
149
139
|
animationRef.current.setDirection(direction === "backward" ? -1 : 1);
|
|
150
140
|
}
|
|
151
141
|
}, [direction]);
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (animationRef.current && playbackRate) {
|
|
154
|
-
animationRef.current.setSpeed(playbackRate);
|
|
155
|
-
}
|
|
156
|
-
}, [playbackRate]);
|
|
157
142
|
useEffect(() => {
|
|
158
143
|
if (!animationRef.current) {
|
|
159
144
|
return;
|
|
160
145
|
}
|
|
161
146
|
const { totalFrames } = animationRef.current;
|
|
162
147
|
const frameToSet = getLottieFrame({
|
|
163
|
-
currentFrame: frame
|
|
148
|
+
currentFrame: frame,
|
|
164
149
|
direction,
|
|
165
|
-
loop,
|
|
166
150
|
totalFrames
|
|
167
151
|
});
|
|
168
152
|
animationRef.current.goToAndStop(frameToSet, true);
|
|
@@ -178,7 +162,7 @@ var LottieContent = ({
|
|
|
178
162
|
}, { once: true });
|
|
179
163
|
img.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", img.href.baseVal);
|
|
180
164
|
});
|
|
181
|
-
}, [direction, frame,
|
|
165
|
+
}, [direction, frame, delayRender, continueRender]);
|
|
182
166
|
return /* @__PURE__ */ jsx("div", {
|
|
183
167
|
ref: containerRef,
|
|
184
168
|
className,
|
|
@@ -186,9 +170,12 @@ var LottieContent = ({
|
|
|
186
170
|
});
|
|
187
171
|
};
|
|
188
172
|
var Lottie = ({
|
|
173
|
+
animationData,
|
|
189
174
|
from,
|
|
190
175
|
durationInFrames,
|
|
191
176
|
trimBefore,
|
|
177
|
+
playbackRate,
|
|
178
|
+
loop,
|
|
192
179
|
freeze,
|
|
193
180
|
hidden,
|
|
194
181
|
name,
|
|
@@ -200,6 +187,12 @@ var Lottie = ({
|
|
|
200
187
|
style,
|
|
201
188
|
...props
|
|
202
189
|
}) => {
|
|
190
|
+
if (typeof animationData !== "object" || animationData === null) {
|
|
191
|
+
throw new Error("animationData should be provided as an object. If you only have the path to the JSON file, load it and pass it as animationData. See https://remotion.dev/docs/lottie/lottie#example for more information.");
|
|
192
|
+
}
|
|
193
|
+
validatePlaybackRate(playbackRate);
|
|
194
|
+
validateLoop(loop);
|
|
195
|
+
const sequenceDurationInFrames = loop && durationInFrames === undefined ? Math.floor(animationData.op - (typeof animationData.ip === "number" ? animationData.ip : 0)) - (trimBefore ?? 0) : durationInFrames;
|
|
203
196
|
const {
|
|
204
197
|
effectivePremountFor,
|
|
205
198
|
effectivePostmountFor,
|
|
@@ -210,7 +203,11 @@ var Lottie = ({
|
|
|
210
203
|
premountingStyle
|
|
211
204
|
} = Internals.usePremounting({
|
|
212
205
|
from: from ?? 0,
|
|
213
|
-
durationInFrames:
|
|
206
|
+
durationInFrames: Internals.resolveSequenceDuration({
|
|
207
|
+
durationInFrames: sequenceDurationInFrames,
|
|
208
|
+
playbackRate,
|
|
209
|
+
loop
|
|
210
|
+
}),
|
|
214
211
|
premountFor: premountFor ?? null,
|
|
215
212
|
postmountFor: postmountFor ?? null,
|
|
216
213
|
style: style ?? null,
|
|
@@ -224,8 +221,10 @@ var Lottie = ({
|
|
|
224
221
|
children: /* @__PURE__ */ jsx(Sequence, {
|
|
225
222
|
layout: "none",
|
|
226
223
|
from,
|
|
227
|
-
durationInFrames,
|
|
224
|
+
durationInFrames: sequenceDurationInFrames,
|
|
228
225
|
trimBefore,
|
|
226
|
+
playbackRate,
|
|
227
|
+
loop,
|
|
229
228
|
freeze,
|
|
230
229
|
hidden,
|
|
231
230
|
name: name ?? "<Lottie>",
|
|
@@ -236,6 +235,7 @@ var Lottie = ({
|
|
|
236
235
|
_remotionInternalIsPostmounting: postmountingActive,
|
|
237
236
|
children: /* @__PURE__ */ jsx(LottieContent, {
|
|
238
237
|
...props,
|
|
238
|
+
animationData,
|
|
239
239
|
style: premountingStyle ?? undefined
|
|
240
240
|
})
|
|
241
241
|
})
|
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.
|
|
6
|
+
"version": "4.0.530",
|
|
7
7
|
"description": "Include Lottie animations in Remotion",
|
|
8
8
|
"main": "dist/cjs/index.js",
|
|
9
9
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"remotion": "4.0.
|
|
28
|
+
"remotion": "4.0.530"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"lottie-web": "^5",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"react": "19.2.3",
|
|
46
46
|
"react-dom": "19.2.3",
|
|
47
47
|
"lottie-web": "5.13.0",
|
|
48
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
48
|
+
"@remotion/eslint-config-internal": "4.0.530",
|
|
49
49
|
"eslint": "9.19.0",
|
|
50
50
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
51
51
|
},
|