@depup/lottie-react 2.4.1-depup.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.
@@ -0,0 +1,653 @@
1
+ import lottie from 'lottie-web';
2
+ export { default as LottiePlayer } from 'lottie-web';
3
+ import React, { useState, useRef, useEffect } from 'react';
4
+
5
+ function _arrayLikeToArray(r, a) {
6
+ (null == a || a > r.length) && (a = r.length);
7
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
8
+ return n;
9
+ }
10
+ function _arrayWithHoles(r) {
11
+ if (Array.isArray(r)) return r;
12
+ }
13
+ function _defineProperty(e, r, t) {
14
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
15
+ value: t,
16
+ enumerable: !0,
17
+ configurable: !0,
18
+ writable: !0
19
+ }) : e[r] = t, e;
20
+ }
21
+ function _iterableToArrayLimit(r, l) {
22
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
23
+ if (null != t) {
24
+ var e,
25
+ n,
26
+ i,
27
+ u,
28
+ a = [],
29
+ f = !0,
30
+ o = !1;
31
+ try {
32
+ if (i = (t = t.call(r)).next, 0 === l) {
33
+ if (Object(t) !== t) return;
34
+ f = !1;
35
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
36
+ } catch (r) {
37
+ o = !0, n = r;
38
+ } finally {
39
+ try {
40
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
41
+ } finally {
42
+ if (o) throw n;
43
+ }
44
+ }
45
+ return a;
46
+ }
47
+ }
48
+ function _nonIterableRest() {
49
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
50
+ }
51
+ function ownKeys(e, r) {
52
+ var t = Object.keys(e);
53
+ if (Object.getOwnPropertySymbols) {
54
+ var o = Object.getOwnPropertySymbols(e);
55
+ r && (o = o.filter(function (r) {
56
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
57
+ })), t.push.apply(t, o);
58
+ }
59
+ return t;
60
+ }
61
+ function _objectSpread2(e) {
62
+ for (var r = 1; r < arguments.length; r++) {
63
+ var t = null != arguments[r] ? arguments[r] : {};
64
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
65
+ _defineProperty(e, r, t[r]);
66
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
67
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
68
+ });
69
+ }
70
+ return e;
71
+ }
72
+ function _objectWithoutProperties(e, t) {
73
+ if (null == e) return {};
74
+ var o,
75
+ r,
76
+ i = _objectWithoutPropertiesLoose(e, t);
77
+ if (Object.getOwnPropertySymbols) {
78
+ var s = Object.getOwnPropertySymbols(e);
79
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
80
+ }
81
+ return i;
82
+ }
83
+ function _objectWithoutPropertiesLoose(r, e) {
84
+ if (null == r) return {};
85
+ var t = {};
86
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
87
+ if (e.includes(n)) continue;
88
+ t[n] = r[n];
89
+ }
90
+ return t;
91
+ }
92
+ function _slicedToArray(r, e) {
93
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
94
+ }
95
+ function _toPrimitive(t, r) {
96
+ if ("object" != typeof t || !t) return t;
97
+ var e = t[Symbol.toPrimitive];
98
+ if (void 0 !== e) {
99
+ var i = e.call(t, r || "default");
100
+ if ("object" != typeof i) return i;
101
+ throw new TypeError("@@toPrimitive must return a primitive value.");
102
+ }
103
+ return ("string" === r ? String : Number)(t);
104
+ }
105
+ function _toPropertyKey(t) {
106
+ var i = _toPrimitive(t, "string");
107
+ return "symbol" == typeof i ? i : i + "";
108
+ }
109
+ function _unsupportedIterableToArray(r, a) {
110
+ if (r) {
111
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
112
+ var t = {}.toString.call(r).slice(8, -1);
113
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
114
+ }
115
+ }
116
+
117
+ var _excluded$1 = ["animationData", "loop", "autoplay", "initialSegment", "onComplete", "onLoopComplete", "onEnterFrame", "onSegmentStart", "onConfigReady", "onDataReady", "onDataFailed", "onLoadedImages", "onDOMLoaded", "onDestroy", "lottieRef", "renderer", "name", "assetsPath", "rendererSettings"];
118
+ var useLottie = function useLottie(props, style) {
119
+ var animationData = props.animationData,
120
+ loop = props.loop,
121
+ autoplay = props.autoplay,
122
+ initialSegment = props.initialSegment,
123
+ onComplete = props.onComplete,
124
+ onLoopComplete = props.onLoopComplete,
125
+ onEnterFrame = props.onEnterFrame,
126
+ onSegmentStart = props.onSegmentStart,
127
+ onConfigReady = props.onConfigReady,
128
+ onDataReady = props.onDataReady,
129
+ onDataFailed = props.onDataFailed,
130
+ onLoadedImages = props.onLoadedImages,
131
+ onDOMLoaded = props.onDOMLoaded,
132
+ onDestroy = props.onDestroy;
133
+ props.lottieRef;
134
+ props.renderer;
135
+ props.name;
136
+ props.assetsPath;
137
+ props.rendererSettings;
138
+ var rest = _objectWithoutProperties(props, _excluded$1);
139
+ var _useState = useState(false),
140
+ _useState2 = _slicedToArray(_useState, 2),
141
+ animationLoaded = _useState2[0],
142
+ setAnimationLoaded = _useState2[1];
143
+ var animationInstanceRef = useRef();
144
+ var animationContainer = useRef(null);
145
+ /*
146
+ ======================================
147
+ INTERACTION METHODS
148
+ ======================================
149
+ */
150
+ /**
151
+ * Play
152
+ */
153
+ var play = function play() {
154
+ var _a;
155
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.play();
156
+ };
157
+ /**
158
+ * Stop
159
+ */
160
+ var stop = function stop() {
161
+ var _a;
162
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.stop();
163
+ };
164
+ /**
165
+ * Pause
166
+ */
167
+ var pause = function pause() {
168
+ var _a;
169
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.pause();
170
+ };
171
+ /**
172
+ * Set animation speed
173
+ * @param speed
174
+ */
175
+ var setSpeed = function setSpeed(speed) {
176
+ var _a;
177
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.setSpeed(speed);
178
+ };
179
+ /**
180
+ * Got to frame and play
181
+ * @param value
182
+ * @param isFrame
183
+ */
184
+ var goToAndPlay = function goToAndPlay(value, isFrame) {
185
+ var _a;
186
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.goToAndPlay(value, isFrame);
187
+ };
188
+ /**
189
+ * Got to frame and stop
190
+ * @param value
191
+ * @param isFrame
192
+ */
193
+ var goToAndStop = function goToAndStop(value, isFrame) {
194
+ var _a;
195
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.goToAndStop(value, isFrame);
196
+ };
197
+ /**
198
+ * Set animation direction
199
+ * @param direction
200
+ */
201
+ var setDirection = function setDirection(direction) {
202
+ var _a;
203
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.setDirection(direction);
204
+ };
205
+ /**
206
+ * Play animation segments
207
+ * @param segments
208
+ * @param forceFlag
209
+ */
210
+ var playSegments = function playSegments(segments, forceFlag) {
211
+ var _a;
212
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.playSegments(segments, forceFlag);
213
+ };
214
+ /**
215
+ * Set sub frames
216
+ * @param useSubFrames
217
+ */
218
+ var setSubframe = function setSubframe(useSubFrames) {
219
+ var _a;
220
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.setSubframe(useSubFrames);
221
+ };
222
+ /**
223
+ * Get animation duration
224
+ * @param inFrames
225
+ */
226
+ var getDuration = function getDuration(inFrames) {
227
+ var _a;
228
+ return (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.getDuration(inFrames);
229
+ };
230
+ /**
231
+ * Destroy animation
232
+ */
233
+ var destroy = function destroy() {
234
+ var _a;
235
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
236
+ // Removing the reference to the animation so separate cleanups are skipped.
237
+ // Without it the internal `lottie-react` instance throws exceptions as it already cleared itself on destroy.
238
+ animationInstanceRef.current = undefined;
239
+ };
240
+ /*
241
+ ======================================
242
+ LOTTIE
243
+ ======================================
244
+ */
245
+ /**
246
+ * Load a new animation, and if it's the case, destroy the previous one
247
+ * @param {Object} forcedConfigs
248
+ */
249
+ var loadAnimation = function loadAnimation() {
250
+ var forcedConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
251
+ var _a;
252
+ // Return if the container ref is null
253
+ if (!animationContainer.current) {
254
+ return;
255
+ }
256
+ // Destroy any previous instance
257
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
258
+ // Build the animation configuration
259
+ var config = _objectSpread2(_objectSpread2(_objectSpread2({}, props), forcedConfigs), {}, {
260
+ container: animationContainer.current
261
+ });
262
+ // Save the animation instance
263
+ animationInstanceRef.current = lottie.loadAnimation(config);
264
+ setAnimationLoaded(!!animationInstanceRef.current);
265
+ // Return a function that will clean up
266
+ return function () {
267
+ var _a;
268
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
269
+ animationInstanceRef.current = undefined;
270
+ };
271
+ };
272
+ /**
273
+ * (Re)Initialize when animation data changed
274
+ */
275
+ useEffect(function () {
276
+ var onUnmount = loadAnimation();
277
+ // Clean up on unmount
278
+ return function () {
279
+ return onUnmount === null || onUnmount === void 0 ? void 0 : onUnmount();
280
+ };
281
+ // eslint-disable-next-line react-hooks/exhaustive-deps
282
+ }, [animationData, loop]);
283
+ // Update the autoplay state
284
+ useEffect(function () {
285
+ if (!animationInstanceRef.current) {
286
+ return;
287
+ }
288
+ animationInstanceRef.current.autoplay = !!autoplay;
289
+ }, [autoplay]);
290
+ // Update the initial segment state
291
+ useEffect(function () {
292
+ if (!animationInstanceRef.current) {
293
+ return;
294
+ }
295
+ // When null should reset to default animation length
296
+ if (!initialSegment) {
297
+ animationInstanceRef.current.resetSegments(true);
298
+ return;
299
+ }
300
+ // If it's not a valid segment, do nothing
301
+ if (!Array.isArray(initialSegment) || !initialSegment.length) {
302
+ return;
303
+ }
304
+ // If the current position it's not in the new segment
305
+ // set the current position to start
306
+ if (animationInstanceRef.current.currentRawFrame < initialSegment[0] || animationInstanceRef.current.currentRawFrame > initialSegment[1]) {
307
+ animationInstanceRef.current.currentRawFrame = initialSegment[0];
308
+ }
309
+ // Update the segment
310
+ animationInstanceRef.current.setSegment(initialSegment[0], initialSegment[1]);
311
+ }, [initialSegment]);
312
+ /*
313
+ ======================================
314
+ EVENTS
315
+ ======================================
316
+ */
317
+ /**
318
+ * Reinitialize listener on change
319
+ */
320
+ useEffect(function () {
321
+ var partialListeners = [{
322
+ name: "complete",
323
+ handler: onComplete
324
+ }, {
325
+ name: "loopComplete",
326
+ handler: onLoopComplete
327
+ }, {
328
+ name: "enterFrame",
329
+ handler: onEnterFrame
330
+ }, {
331
+ name: "segmentStart",
332
+ handler: onSegmentStart
333
+ }, {
334
+ name: "config_ready",
335
+ handler: onConfigReady
336
+ }, {
337
+ name: "data_ready",
338
+ handler: onDataReady
339
+ }, {
340
+ name: "data_failed",
341
+ handler: onDataFailed
342
+ }, {
343
+ name: "loaded_images",
344
+ handler: onLoadedImages
345
+ }, {
346
+ name: "DOMLoaded",
347
+ handler: onDOMLoaded
348
+ }, {
349
+ name: "destroy",
350
+ handler: onDestroy
351
+ }];
352
+ var listeners = partialListeners.filter(function (listener) {
353
+ return listener.handler != null;
354
+ });
355
+ if (!listeners.length) {
356
+ return;
357
+ }
358
+ var deregisterList = listeners.map(
359
+ /**
360
+ * Handle the process of adding an event listener
361
+ * @param {Listener} listener
362
+ * @return {Function} Function that deregister the listener
363
+ */
364
+ function (listener) {
365
+ var _a;
366
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener(listener.name, listener.handler);
367
+ // Return a function to deregister this listener
368
+ return function () {
369
+ var _a;
370
+ (_a = animationInstanceRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener(listener.name, listener.handler);
371
+ };
372
+ });
373
+ // Deregister listeners on unmount
374
+ return function () {
375
+ deregisterList.forEach(function (deregister) {
376
+ return deregister();
377
+ });
378
+ };
379
+ }, [onComplete, onLoopComplete, onEnterFrame, onSegmentStart, onConfigReady, onDataReady, onDataFailed, onLoadedImages, onDOMLoaded, onDestroy]);
380
+ /**
381
+ * Build the animation view
382
+ */
383
+ var View = /*#__PURE__*/React.createElement("div", _objectSpread2({
384
+ style: style,
385
+ ref: animationContainer
386
+ }, rest));
387
+ return {
388
+ View: View,
389
+ play: play,
390
+ stop: stop,
391
+ pause: pause,
392
+ setSpeed: setSpeed,
393
+ goToAndStop: goToAndStop,
394
+ goToAndPlay: goToAndPlay,
395
+ setDirection: setDirection,
396
+ playSegments: playSegments,
397
+ setSubframe: setSubframe,
398
+ getDuration: getDuration,
399
+ destroy: destroy,
400
+ animationContainerRef: animationContainer,
401
+ animationLoaded: animationLoaded,
402
+ animationItem: animationInstanceRef.current
403
+ };
404
+ };
405
+
406
+ // helpers
407
+ function getContainerVisibility(container) {
408
+ var _container$getBoundin = container.getBoundingClientRect(),
409
+ top = _container$getBoundin.top,
410
+ height = _container$getBoundin.height;
411
+ var current = window.innerHeight - top;
412
+ var max = window.innerHeight + height;
413
+ return current / max;
414
+ }
415
+ function getContainerCursorPosition(container, cursorX, cursorY) {
416
+ var _container$getBoundin2 = container.getBoundingClientRect(),
417
+ top = _container$getBoundin2.top,
418
+ left = _container$getBoundin2.left,
419
+ width = _container$getBoundin2.width,
420
+ height = _container$getBoundin2.height;
421
+ var x = (cursorX - left) / width;
422
+ var y = (cursorY - top) / height;
423
+ return {
424
+ x: x,
425
+ y: y
426
+ };
427
+ }
428
+ var useInitInteractivity = function useInitInteractivity(_ref) {
429
+ var wrapperRef = _ref.wrapperRef,
430
+ animationItem = _ref.animationItem,
431
+ mode = _ref.mode,
432
+ actions = _ref.actions;
433
+ useEffect(function () {
434
+ var wrapper = wrapperRef.current;
435
+ if (!wrapper || !animationItem || !actions.length) {
436
+ return;
437
+ }
438
+ animationItem.stop();
439
+ var scrollModeHandler = function scrollModeHandler() {
440
+ var assignedSegment = null;
441
+ var scrollHandler = function scrollHandler() {
442
+ var currentPercent = getContainerVisibility(wrapper);
443
+ // Find the first action that satisfies the current position conditions
444
+ var action = actions.find(function (_ref2) {
445
+ var visibility = _ref2.visibility;
446
+ return visibility && currentPercent >= visibility[0] && currentPercent <= visibility[1];
447
+ });
448
+ // Skip if no matching action was found!
449
+ if (!action) {
450
+ return;
451
+ }
452
+ if (action.type === "seek" && action.visibility && action.frames.length === 2) {
453
+ // Seek: Go to a frame based on player scroll position action
454
+ var frameToGo = action.frames[0] + Math.ceil((currentPercent - action.visibility[0]) / (action.visibility[1] - action.visibility[0]) * action.frames[1]);
455
+ //! goToAndStop must be relative to the start of the current segment
456
+ animationItem.goToAndStop(frameToGo - animationItem.firstFrame - 1, true);
457
+ }
458
+ if (action.type === "loop") {
459
+ // Loop: Loop a given frames
460
+ if (assignedSegment === null) {
461
+ // if not playing any segments currently. play those segments and save to state
462
+ animationItem.playSegments(action.frames, true);
463
+ assignedSegment = action.frames;
464
+ } else {
465
+ // if playing any segments currently.
466
+ //check if segments in state are equal to the frames selected by action
467
+ if (assignedSegment !== action.frames) {
468
+ // if they are not equal. new segments are to be loaded
469
+ animationItem.playSegments(action.frames, true);
470
+ assignedSegment = action.frames;
471
+ } else if (animationItem.isPaused) {
472
+ // if they are equal the play method must be called only if lottie is paused
473
+ animationItem.playSegments(action.frames, true);
474
+ assignedSegment = action.frames;
475
+ }
476
+ }
477
+ }
478
+ if (action.type === "play" && animationItem.isPaused) {
479
+ // Play: Reset segments and continue playing full animation from current position
480
+ animationItem.resetSegments(true);
481
+ animationItem.play();
482
+ }
483
+ if (action.type === "stop") {
484
+ // Stop: Stop playback
485
+ animationItem.goToAndStop(action.frames[0] - animationItem.firstFrame - 1, true);
486
+ }
487
+ };
488
+ document.addEventListener("scroll", scrollHandler);
489
+ return function () {
490
+ document.removeEventListener("scroll", scrollHandler);
491
+ };
492
+ };
493
+ var cursorModeHandler = function cursorModeHandler() {
494
+ var handleCursor = function handleCursor(_x, _y) {
495
+ var x = _x;
496
+ var y = _y;
497
+ // Resolve cursor position if cursor is inside container
498
+ if (x !== -1 && y !== -1) {
499
+ // Get container cursor position
500
+ var pos = getContainerCursorPosition(wrapper, x, y);
501
+ // Use the resolved position
502
+ x = pos.x;
503
+ y = pos.y;
504
+ }
505
+ // Find the first action that satisfies the current position conditions
506
+ var action = actions.find(function (_ref3) {
507
+ var position = _ref3.position;
508
+ if (position && Array.isArray(position.x) && Array.isArray(position.y)) {
509
+ return x >= position.x[0] && x <= position.x[1] && y >= position.y[0] && y <= position.y[1];
510
+ }
511
+ if (position && !Number.isNaN(position.x) && !Number.isNaN(position.y)) {
512
+ return x === position.x && y === position.y;
513
+ }
514
+ return false;
515
+ });
516
+ // Skip if no matching action was found!
517
+ if (!action) {
518
+ return;
519
+ }
520
+ // Process action types:
521
+ if (action.type === "seek" && action.position && Array.isArray(action.position.x) && Array.isArray(action.position.y) && action.frames.length === 2) {
522
+ // Seek: Go to a frame based on player scroll position action
523
+ var xPercent = (x - action.position.x[0]) / (action.position.x[1] - action.position.x[0]);
524
+ var yPercent = (y - action.position.y[0]) / (action.position.y[1] - action.position.y[0]);
525
+ animationItem.playSegments(action.frames, true);
526
+ animationItem.goToAndStop(Math.ceil((xPercent + yPercent) / 2 * (action.frames[1] - action.frames[0])), true);
527
+ }
528
+ if (action.type === "loop") {
529
+ animationItem.playSegments(action.frames, true);
530
+ }
531
+ if (action.type === "play") {
532
+ // Play: Reset segments and continue playing full animation from current position
533
+ if (animationItem.isPaused) {
534
+ animationItem.resetSegments(false);
535
+ }
536
+ animationItem.playSegments(action.frames);
537
+ }
538
+ if (action.type === "stop") {
539
+ animationItem.goToAndStop(action.frames[0], true);
540
+ }
541
+ };
542
+ var mouseMoveHandler = function mouseMoveHandler(ev) {
543
+ handleCursor(ev.clientX, ev.clientY);
544
+ };
545
+ var mouseOutHandler = function mouseOutHandler() {
546
+ handleCursor(-1, -1);
547
+ };
548
+ wrapper.addEventListener("mousemove", mouseMoveHandler);
549
+ wrapper.addEventListener("mouseout", mouseOutHandler);
550
+ return function () {
551
+ wrapper.removeEventListener("mousemove", mouseMoveHandler);
552
+ wrapper.removeEventListener("mouseout", mouseOutHandler);
553
+ };
554
+ };
555
+ switch (mode) {
556
+ case "scroll":
557
+ return scrollModeHandler();
558
+ case "cursor":
559
+ return cursorModeHandler();
560
+ }
561
+ // eslint-disable-next-line react-hooks/exhaustive-deps
562
+ }, [mode, animationItem]);
563
+ };
564
+ var useLottieInteractivity = function useLottieInteractivity(_ref4) {
565
+ var actions = _ref4.actions,
566
+ mode = _ref4.mode,
567
+ lottieObj = _ref4.lottieObj;
568
+ var animationItem = lottieObj.animationItem,
569
+ View = lottieObj.View,
570
+ animationContainerRef = lottieObj.animationContainerRef;
571
+ useInitInteractivity({
572
+ actions: actions,
573
+ animationItem: animationItem,
574
+ mode: mode,
575
+ wrapperRef: animationContainerRef
576
+ });
577
+ return View;
578
+ };
579
+
580
+ var _excluded = ["style", "interactivity"];
581
+ var Lottie = function Lottie(props) {
582
+ var _a, _b, _c;
583
+ var style = props.style,
584
+ interactivity = props.interactivity,
585
+ lottieProps = _objectWithoutProperties(props, _excluded);
586
+ /**
587
+ * Initialize the 'useLottie' hook
588
+ */
589
+ var _useLottie = useLottie(lottieProps, style),
590
+ View = _useLottie.View,
591
+ play = _useLottie.play,
592
+ stop = _useLottie.stop,
593
+ pause = _useLottie.pause,
594
+ setSpeed = _useLottie.setSpeed,
595
+ goToAndStop = _useLottie.goToAndStop,
596
+ goToAndPlay = _useLottie.goToAndPlay,
597
+ setDirection = _useLottie.setDirection,
598
+ playSegments = _useLottie.playSegments,
599
+ setSubframe = _useLottie.setSubframe,
600
+ getDuration = _useLottie.getDuration,
601
+ destroy = _useLottie.destroy,
602
+ animationContainerRef = _useLottie.animationContainerRef,
603
+ animationLoaded = _useLottie.animationLoaded,
604
+ animationItem = _useLottie.animationItem;
605
+ /**
606
+ * Make the hook variables/methods available through the provided 'lottieRef'
607
+ */
608
+ useEffect(function () {
609
+ if (props.lottieRef) {
610
+ props.lottieRef.current = {
611
+ play: play,
612
+ stop: stop,
613
+ pause: pause,
614
+ setSpeed: setSpeed,
615
+ goToAndPlay: goToAndPlay,
616
+ goToAndStop: goToAndStop,
617
+ setDirection: setDirection,
618
+ playSegments: playSegments,
619
+ setSubframe: setSubframe,
620
+ getDuration: getDuration,
621
+ destroy: destroy,
622
+ animationContainerRef: animationContainerRef,
623
+ animationLoaded: animationLoaded,
624
+ animationItem: animationItem
625
+ };
626
+ }
627
+ // eslint-disable-next-line react-hooks/exhaustive-deps
628
+ }, [(_a = props.lottieRef) === null || _a === void 0 ? void 0 : _a.current]);
629
+ return useLottieInteractivity({
630
+ lottieObj: {
631
+ View: View,
632
+ play: play,
633
+ stop: stop,
634
+ pause: pause,
635
+ setSpeed: setSpeed,
636
+ goToAndStop: goToAndStop,
637
+ goToAndPlay: goToAndPlay,
638
+ setDirection: setDirection,
639
+ playSegments: playSegments,
640
+ setSubframe: setSubframe,
641
+ getDuration: getDuration,
642
+ destroy: destroy,
643
+ animationContainerRef: animationContainerRef,
644
+ animationLoaded: animationLoaded,
645
+ animationItem: animationItem
646
+ },
647
+ actions: (_b = interactivity === null || interactivity === void 0 ? void 0 : interactivity.actions) !== null && _b !== void 0 ? _b : [],
648
+ mode: (_c = interactivity === null || interactivity === void 0 ? void 0 : interactivity.mode) !== null && _c !== void 0 ? _c : "scroll"
649
+ });
650
+ };
651
+
652
+ export { Lottie as default, useLottie, useLottieInteractivity };
653
+ //# sourceMappingURL=index.es.js.map