react-lottie 2.0.0 → 2.1.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.
- package/CHANGELOG.md +17 -0
- package/README.md +26 -4
- package/dist/index.js +37 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.1.0](https://github.com/chenqingspring/react-lottie/compare/v2.0.1...v2.1.0) (2026-11-05)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* add an `isSubframe` prop that is passed to lottie-web's `setSubframe()`, so `enterFrame` can fire only on whole After Effects frames, e.g. to trigger audio exactly on frame boundaries ([#71](https://github.com/chenqingspring/react-lottie/issues/71))
|
|
10
|
+
* expose `goToAndStop(frame, isFrame)` and `goToAndPlay(frame, isFrame)` on the component instance, which makes it possible to drive an animation from scroll position or jump to an exact frame/marker through a `ref` ([#40](https://github.com/chenqingspring/react-lottie/issues/40))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* keep a playing animation running when an unrelated prop changes; added a regression test for the state-change pause reported in [#43](https://github.com/chenqingspring/react-lottie/issues/43)
|
|
15
|
+
|
|
16
|
+
## [2.0.1](https://github.com/chenqingspring/react-lottie/compare/v2.0.0...v2.0.1) (2026-11-05)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* apply the `segments` prop on mount, so an animation starts inside the requested range instead of playing the full timeline until the prop changes; an animation created with `autoplay: false` stays paused at the start of the range
|
|
21
|
+
|
|
5
22
|
## [2.0.0](https://github.com/chenqingspring/react-lottie/compare/v1.2.10...v2.0.0) (2026-11-04)
|
|
6
23
|
|
|
7
24
|
This release folds in the changes that were prepared as 1.2.11 (never
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/js/react-lottie)
|
|
4
4
|
|
|
5
|
+
> **This project is fully maintained automatically by [Relay](https://get-relay.cc).**
|
|
6
|
+
|
|
5
7
|
## Demo
|
|
6
8
|
https://chenqingspring.github.io/react-lottie
|
|
7
9
|
|
|
@@ -31,10 +33,7 @@ Install through npm:
|
|
|
31
33
|
npm install --save react-lottie
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
> **Note:**
|
|
35
|
-
> [get-relay.cc](https://get-relay.cc).
|
|
36
|
-
>
|
|
37
|
-
> Found a bug or have a feature request? Open an issue on
|
|
36
|
+
> **Note:** Found a bug or have a feature request? Open an issue on
|
|
38
37
|
> [GitHub](https://github.com/chenqingspring/react-lottie/issues) and Relay
|
|
39
38
|
> will review and fix it.
|
|
40
39
|
|
|
@@ -188,6 +187,22 @@ A segment also has to be reachable with `loop`/`autoplay` as usual: with
|
|
|
188
187
|
`loop: false` and `autoplay: false` the range only plays once you flip
|
|
189
188
|
`isStopped` or pass a new `segments` value.
|
|
190
189
|
|
|
190
|
+
### Imperative control
|
|
191
|
+
|
|
192
|
+
A `ref` to the component exposes `play()`, `pause()`, `stop()`,
|
|
193
|
+
`playSegments()`, `goToAndStop(frame, isFrame)` and
|
|
194
|
+
`goToAndPlay(frame, isFrame)`, mirroring the lottie-web animation object. Use
|
|
195
|
+
`isFrame: true` for a frame number, or omit it to pass a time in seconds. This
|
|
196
|
+
is how you can sync an animation to scroll position (issue #40):
|
|
197
|
+
|
|
198
|
+
```jsx
|
|
199
|
+
const lottie = useRef(null);
|
|
200
|
+
|
|
201
|
+
const onScroll = (frame) => lottie.current.goToAndStop(frame, true);
|
|
202
|
+
|
|
203
|
+
<Lottie ref={lottie} options={defaultOptions} />
|
|
204
|
+
```
|
|
205
|
+
|
|
191
206
|
### props
|
|
192
207
|
The `<Lottie />` Component supports the following props:
|
|
193
208
|
|
|
@@ -235,6 +250,13 @@ values play in reverse at that rate.
|
|
|
235
250
|
`1` plays forward, `-1` plays backward. Changing it keeps the current frame,
|
|
236
251
|
which is what you want for hover-in / hover-out effects.
|
|
237
252
|
|
|
253
|
+
**isSubframe** *optional* [default: `true`]
|
|
254
|
+
|
|
255
|
+
Passed to lottie-web's `setSubframe()`. When `true`, frames are interpolated
|
|
256
|
+
for smooth playback. Set it to `false` to make the `enterFrame` event fire only
|
|
257
|
+
on whole After Effects frames, for example to trigger audio exactly on frame
|
|
258
|
+
boundaries (issue #71).
|
|
259
|
+
|
|
238
260
|
**segments** *optional* [default: none]
|
|
239
261
|
|
|
240
262
|
`[fromFrame, toFrame]` to play only part of the animation, e.g. `[45, 90]`.
|
package/dist/index.js
CHANGED
|
@@ -78,6 +78,18 @@ var Lottie = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
|
78
78
|
this.registerEvents(eventListeners);
|
|
79
79
|
this.setSpeed();
|
|
80
80
|
this.setDirection();
|
|
81
|
+
this.setSubframe();
|
|
82
|
+
|
|
83
|
+
/* Apply a segment passed on mount. The component otherwise only reacts to
|
|
84
|
+
`segments` changes, so the animation used to play the whole timeline
|
|
85
|
+
until the prop was updated. */
|
|
86
|
+
if (this.props.segments && this.props.segments.length === 2) {
|
|
87
|
+
var wasPaused = this.anim.isPaused;
|
|
88
|
+
this.playSegments();
|
|
89
|
+
if (wasPaused) {
|
|
90
|
+
this.pause();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
81
93
|
|
|
82
94
|
/* Apply the initial playback props, which are otherwise only read on update */
|
|
83
95
|
if (this.props.isStopped) {
|
|
@@ -121,6 +133,7 @@ var Lottie = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
|
121
133
|
}
|
|
122
134
|
this.setSpeed();
|
|
123
135
|
this.setDirection();
|
|
136
|
+
this.setSubframe();
|
|
124
137
|
}
|
|
125
138
|
}, {
|
|
126
139
|
key: "componentWillUnmount",
|
|
@@ -140,11 +153,33 @@ var Lottie = exports["default"] = /*#__PURE__*/function (_React$Component) {
|
|
|
140
153
|
value: function setDirection() {
|
|
141
154
|
this.anim.setDirection(this.props.direction);
|
|
142
155
|
}
|
|
156
|
+
|
|
157
|
+
/* `isSubframe` mirrors lottie-web's setSubframe(): with it enabled (the
|
|
158
|
+
default) frames are interpolated, with it disabled `enterFrame` fires only
|
|
159
|
+
on whole After Effects frames (issue #71). */
|
|
160
|
+
}, {
|
|
161
|
+
key: "setSubframe",
|
|
162
|
+
value: function setSubframe() {
|
|
163
|
+
this.anim.setSubframe(this.props.isSubframe);
|
|
164
|
+
}
|
|
143
165
|
}, {
|
|
144
166
|
key: "play",
|
|
145
167
|
value: function play() {
|
|
146
168
|
this.anim.play();
|
|
147
169
|
}
|
|
170
|
+
|
|
171
|
+
/* Frame/marker control from a ref, e.g. to sync an animation to scroll.
|
|
172
|
+
`isFrame` false treats the value as a time in seconds (issue #40). */
|
|
173
|
+
}, {
|
|
174
|
+
key: "goToAndStop",
|
|
175
|
+
value: function goToAndStop(value, isFrame) {
|
|
176
|
+
this.anim.goToAndStop(value, isFrame);
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "goToAndPlay",
|
|
180
|
+
value: function goToAndPlay(value, isFrame) {
|
|
181
|
+
this.anim.goToAndPlay(value, isFrame);
|
|
182
|
+
}
|
|
148
183
|
}, {
|
|
149
184
|
key: "playSegments",
|
|
150
185
|
value: function playSegments() {
|
|
@@ -247,6 +282,7 @@ Lottie.propTypes = {
|
|
|
247
282
|
speed: _propTypes["default"].number,
|
|
248
283
|
segments: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
249
284
|
direction: _propTypes["default"].number,
|
|
285
|
+
isSubframe: _propTypes["default"].bool,
|
|
250
286
|
ariaRole: _propTypes["default"].string,
|
|
251
287
|
ariaLabel: _propTypes["default"].string,
|
|
252
288
|
isClickToPauseDisabled: _propTypes["default"].bool,
|
|
@@ -259,6 +295,7 @@ Lottie.defaultProps = {
|
|
|
259
295
|
isStopped: false,
|
|
260
296
|
isPaused: false,
|
|
261
297
|
speed: 1,
|
|
298
|
+
isSubframe: true,
|
|
262
299
|
ariaRole: 'button',
|
|
263
300
|
ariaLabel: 'animation',
|
|
264
301
|
isClickToPauseDisabled: false,
|