react-lottie 2.0.1 → 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 CHANGED
@@ -2,6 +2,17 @@
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
+
5
16
  ## [2.0.1](https://github.com/chenqingspring/react-lottie/compare/v2.0.0...v2.0.1) (2026-11-05)
6
17
 
7
18
  ### Bug Fixes
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/react-lottie.svg)](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:** react-lottie is maintained automatically by Relay. Learn more at
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,7 @@ var Lottie = exports["default"] = /*#__PURE__*/function (_React$Component) {
78
78
  this.registerEvents(eventListeners);
79
79
  this.setSpeed();
80
80
  this.setDirection();
81
+ this.setSubframe();
81
82
 
82
83
  /* Apply a segment passed on mount. The component otherwise only reacts to
83
84
  `segments` changes, so the animation used to play the whole timeline
@@ -132,6 +133,7 @@ var Lottie = exports["default"] = /*#__PURE__*/function (_React$Component) {
132
133
  }
133
134
  this.setSpeed();
134
135
  this.setDirection();
136
+ this.setSubframe();
135
137
  }
136
138
  }, {
137
139
  key: "componentWillUnmount",
@@ -151,11 +153,33 @@ var Lottie = exports["default"] = /*#__PURE__*/function (_React$Component) {
151
153
  value: function setDirection() {
152
154
  this.anim.setDirection(this.props.direction);
153
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
+ }
154
165
  }, {
155
166
  key: "play",
156
167
  value: function play() {
157
168
  this.anim.play();
158
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
+ }
159
183
  }, {
160
184
  key: "playSegments",
161
185
  value: function playSegments() {
@@ -258,6 +282,7 @@ Lottie.propTypes = {
258
282
  speed: _propTypes["default"].number,
259
283
  segments: _propTypes["default"].arrayOf(_propTypes["default"].number),
260
284
  direction: _propTypes["default"].number,
285
+ isSubframe: _propTypes["default"].bool,
261
286
  ariaRole: _propTypes["default"].string,
262
287
  ariaLabel: _propTypes["default"].string,
263
288
  isClickToPauseDisabled: _propTypes["default"].bool,
@@ -270,6 +295,7 @@ Lottie.defaultProps = {
270
295
  isStopped: false,
271
296
  isPaused: false,
272
297
  speed: 1,
298
+ isSubframe: true,
273
299
  ariaRole: 'button',
274
300
  ariaLabel: 'animation',
275
301
  isClickToPauseDisabled: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-lottie",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "funding": "https://opencollective.com/react-lottie",
5
5
  "description": "lottie animation view for React",
6
6
  "repository": {