reacthub-pixitweenjs 0.2.3 → 0.2.5

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.
Files changed (57) hide show
  1. package/.storybook/{main.js → main.ts} +9 -1
  2. package/.storybook/{preview.jsx → preview.tsx} +3 -7
  3. package/CHANGELOG.md +40 -0
  4. package/README.md +21 -2
  5. package/build-storybook.log +94 -0
  6. package/index.html +1 -1
  7. package/package.json +68 -36
  8. package/src/App.tsx +29 -0
  9. package/src/components/PixiAnimatedSprite/PixiAnimatedSprite.tsx +51 -0
  10. package/src/components/PixiAnimatedSprite/index.ts +2 -0
  11. package/src/components/PixiAudioSprite/PixiAudioSprite.stories.tsx +61 -0
  12. package/src/components/PixiAudioSprite/PixiAudioSprite.tsx +212 -0
  13. package/src/components/PixiAudioSprite/index.ts +1 -0
  14. package/src/components/PixiGifSprite/PixiGifSprite.stories.tsx +135 -0
  15. package/src/components/PixiGifSprite/PixiGifSprite.tsx +451 -0
  16. package/src/components/PixiGifSprite/index.ts +2 -0
  17. package/src/{stories/PixiImageSprite/PixiImageSprite.stories.js → components/PixiImageSprite/PixiImageSprite.stories.tsx} +36 -8
  18. package/src/components/PixiImageSprite/PixiImageSprite.tsx +340 -0
  19. package/src/components/PixiImageSprite/index.ts +1 -0
  20. package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +137 -0
  21. package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +378 -0
  22. package/src/components/PixiSVGSprite/index.ts +1 -0
  23. package/src/components/PixiVideoSprite/PixiVideoSprite.stories.tsx +147 -0
  24. package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +684 -0
  25. package/src/components/PixiVideoSprite/PixiVideoSpriteBackup.txt +755 -0
  26. package/src/components/PixiVideoSprite/index.ts +1 -0
  27. package/src/declare.module.ts +5 -0
  28. package/src/hooks/usePixiTransformer.tsx +168 -0
  29. package/src/index.ts +3 -0
  30. package/src/providers/GsapPixieContextProvider.tsx +251 -0
  31. package/src/providers/index.ts +1 -0
  32. package/src/reacthub-react-bindings.d.ts +27 -0
  33. package/src/types/transformation.tsx +13 -0
  34. package/src/utils/AppStateProvider.tsx +59 -0
  35. package/src/utils/AppStateStage.tsx +27 -0
  36. package/src/utils/AppWrapper.tsx +43 -0
  37. package/src/utils/ContextBridge.tsx +25 -0
  38. package/src/{providers/GsapAnim.jsx → utils/GsapAnim.tsx} +35 -4
  39. package/src/utils/PixiStage.tsx +29 -0
  40. package/src/utils/PixiTransformer.tsx +100 -0
  41. package/src/utils/VideoSeekBar.tsx +129 -0
  42. package/src/utils/useDebounce.tsx +15 -0
  43. package/src/utils/useDeepEffect.tsx +23 -0
  44. package/src/vite-env.d.ts +1 -0
  45. package/tsconfig.json +37 -0
  46. package/tsconfig.node.json +10 -0
  47. package/{vite.config.js → vite.config.ts} +4 -2
  48. package/vitest.config.ts +11 -0
  49. package/src/App.jsx +0 -35
  50. package/src/index.js +0 -3
  51. package/src/providers/ContextBridge.jsx +0 -67
  52. package/src/providers/GsapPixieContextProvider.jsx +0 -162
  53. package/src/providers/VideoSeekBar.jsx +0 -186
  54. package/src/providers/index.js +0 -3
  55. package/src/stories/PixiImageSprite/PixiImageSprite.jsx +0 -318
  56. package/src/stories/PixiImageSprite/index.js +0 -1
  57. /package/src/{main.jsx → main.tsx} +0 -0
@@ -0,0 +1,684 @@
1
+ import * as React from "react";
2
+ import { useContext, useEffect, useRef, useState } from "react";
3
+ // @ts-ignore
4
+ import PropTypes from "prop-types";
5
+ import { useCustomEventListener } from "react-custom-events";
6
+ import {
7
+ GsapPixieContext,
8
+ Events,
9
+ } from "../../providers/GsapPixieContextProvider";
10
+ import { Sprite, Container, useApp, withFilters } from "@pixi/react";
11
+ import { AdjustmentFilter } from "@pixi/filter-adjustment";
12
+ import * as PIXI from "pixi.js";
13
+ import gsap from "gsap";
14
+ import PixiTransformer from "../../utils/PixiTransformer";
15
+
16
+ // @ts-ignore
17
+ import isEmpty from "lodash/isEmpty";
18
+ import { getAnimByName } from "../../utils/GsapAnim";
19
+ import { TransformationEnd } from "../../types/transformation";
20
+
21
+ type PixiVideoSpriteProps = {
22
+ uniqueId: string;
23
+ src: string;
24
+ startAt: number;
25
+ endAt: number;
26
+ frameStartAt: number;
27
+ frameEndAt: number;
28
+ mute: boolean;
29
+ locked: boolean;
30
+ initialAlpha: number;
31
+ transformation: {
32
+ x: number;
33
+ y: number;
34
+ width: number;
35
+ height: number;
36
+ anchor: number;
37
+ rotation?: number;
38
+ alpha?: number;
39
+ scale?: number | [number, number];
40
+ tint?: number;
41
+ blendMode?: number;
42
+ animation?: string;
43
+ colorCorrection?: {
44
+ enabled?: boolean;
45
+ temperature?: number;
46
+ hue?: number;
47
+ contrast?: number;
48
+ saturation?: number;
49
+ exposure?: number;
50
+ reset?: boolean;
51
+ sharpness?: number;
52
+ value?: number;
53
+ levels?: number;
54
+ luminance?: number;
55
+ enhance?: number;
56
+ blurRadius?: number;
57
+ red?: number;
58
+ green?: number;
59
+ blue?: number;
60
+ alpha?: number;
61
+ scaleInput?: number;
62
+ };
63
+ effect?: string;
64
+ };
65
+ pointerdown?: () => void;
66
+ pointerup?: () => void;
67
+ mousedown?: () => void;
68
+ mouseup?: () => void;
69
+ pointerover?: () => void;
70
+ mouseover?: () => void;
71
+ mouseout?: () => void;
72
+ applyTransformer?: boolean;
73
+ onAnchorTransformationEnd?: (endData: any) => void;
74
+ };
75
+
76
+ type EffectFunc = () => void;
77
+ type Deps = ReadonlyArray<unknown>;
78
+
79
+ interface VideoState {
80
+ isPlaying: boolean;
81
+ progress: number;
82
+ speed: number;
83
+ isMuted: boolean;
84
+ isWaiting: boolean;
85
+ loaded: boolean;
86
+ size: { width: number; height: number };
87
+ isDragging: boolean;
88
+ }
89
+
90
+ const Filters = withFilters(Container, {
91
+ blur: PIXI.filters.BlurFilter,
92
+ adjust: AdjustmentFilter,
93
+ matrix: PIXI.filters.ColorMatrixFilter,
94
+ });
95
+
96
+ /** filter config */
97
+ const config = {
98
+ dot: {
99
+ scale: 1,
100
+ angle: 5,
101
+ },
102
+ blur: {
103
+ blur: 0,
104
+ quality: 4,
105
+ },
106
+ };
107
+
108
+ /** CYAN Filters */
109
+ const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
110
+
111
+ const initialState: VideoState = {
112
+ isPlaying: false,
113
+ progress: 0,
114
+ speed: 1,
115
+ isMuted: false,
116
+ isWaiting: false,
117
+ loaded: false,
118
+ size: { width: 50, height: 50 },
119
+ isDragging: false,
120
+ };
121
+
122
+ const PixiVideoSprite: React.FC<PixiVideoSpriteProps> = (props) => {
123
+ //// State
124
+ const [isMounted, setIsMounted] = React.useState(false);
125
+ const [vidPlay, setVidPlay] = React.useState(false);
126
+ const [isTransformerDragging, setIsTransformerDragging] = useState(false);
127
+ const [isMouseOverTransformer, setIsMouseOverTransformer] = useState(false);
128
+ const [{ isWaiting, isStalled }, setVideoState] = React.useState({
129
+ isWaiting: false,
130
+ isStalled: false,
131
+ });
132
+ const [videoTexture, setVideoTexture] =
133
+ React.useState<PIXI.Texture<PIXI.Resource>>();
134
+ const [isDragging, setIsDragging] = useState(false);
135
+
136
+ console.log("PixiVideoSpriteProps", props);
137
+ //// Refs
138
+ const imageRef = useRef<PIXI.Sprite>(null);
139
+ const containerRef = useRef<PIXI.Container>(null);
140
+ const parentNode = useRef<PIXI.Container>(null);
141
+ const imgGroupRef = useRef<PIXI.Container>(null);
142
+ const transformerRef = useRef<PIXI.Container>(null);
143
+ const videoElement = useRef<HTMLVideoElement>(null);
144
+ const videoStateRef = useRef<VideoState>(initialState);
145
+
146
+ //// Context
147
+ const {
148
+ tl,
149
+ playerTimeRef,
150
+ isDragging: gsapDragging,
151
+ play,
152
+ } = useContext(GsapPixieContext);
153
+
154
+ // console log draggging
155
+ console.log("isGsapDragging", gsapDragging);
156
+ console.log("play", play);
157
+ /// 1001
158
+ // console.log("contxt Values", tl);
159
+ const {
160
+ uniqueId,
161
+ mute = false,
162
+ locked = false,
163
+ src,
164
+ startAt,
165
+ endAt,
166
+ frameStartAt,
167
+ frameEndAt,
168
+ initialAlpha,
169
+ transformation: {
170
+ x,
171
+ y,
172
+ width,
173
+ height,
174
+ scale,
175
+ rotation,
176
+ anchor,
177
+ animation,
178
+ colorCorrection,
179
+ effect,
180
+ },
181
+ pointerdown,
182
+ pointerup,
183
+ mousedown,
184
+ mouseup,
185
+ pointerover,
186
+ mouseover,
187
+ mouseout,
188
+ applyTransformer,
189
+ onAnchorTransformationEnd,
190
+ ...restProps
191
+ } = props;
192
+
193
+ const videoUrl = src || "";
194
+
195
+ // color corrections
196
+ const {
197
+ enabled = false,
198
+ temperature = 1,
199
+ hue = 1,
200
+ contrast = 1,
201
+ saturation = 1,
202
+ exposure = 1,
203
+ reset,
204
+ sharpness = 1,
205
+ value = 0,
206
+ levels = 1,
207
+ luminance = 0,
208
+ enhance = 0,
209
+ blurRadius = 0,
210
+ red = 150,
211
+ green = 150,
212
+ blue = 150,
213
+ alpha = 1,
214
+ scaleInput = 1,
215
+ } = colorCorrection || {};
216
+
217
+ const app = useApp();
218
+
219
+ /** adjustment filter */
220
+ const adjustments = {
221
+ brightness: exposure,
222
+ contrast,
223
+ saturation,
224
+ alpha,
225
+ };
226
+
227
+ /** handle on tranformer onchange */
228
+ const handleOnTransformChange = React.useCallback(() => {
229
+ setIsDragging(true);
230
+ }, []);
231
+
232
+ // transformer to handle sprite transformation
233
+ const handleOnTransformEnd = React.useCallback(
234
+ (endData: TransformationEnd) => {
235
+ console.log("changeEnd", endData);
236
+ if (onAnchorTransformationEnd) {
237
+ console.log("running onAnchorTransformationEnd");
238
+ onAnchorTransformationEnd(endData);
239
+ }
240
+ },
241
+ []
242
+ );
243
+
244
+ /**Adding this alternative workaround to work with mov/mk4 video types */
245
+ const videoSrcElement = React.useMemo(() => {
246
+ const element = document.createElement("video");
247
+ element.src = src;
248
+ element.crossOrigin = "Anonymus";
249
+ element.autoplay = false;
250
+ element.currentTime = 0.0001;
251
+ return element;
252
+ }, [src]);
253
+
254
+ /** Adding custom event listners */
255
+ /** Event Listeneres */
256
+ useCustomEventListener(Events.PAUSE, (data) => {
257
+ console.log("pause event", data);
258
+ if (videoElement.current) {
259
+ const vid = videoElement.current;
260
+ const isVidPlaying =
261
+ vid.currentTime > 0 &&
262
+ !vid.paused &&
263
+ !vid.ended &&
264
+ vid.readyState > vid.HAVE_CURRENT_DATA;
265
+ if (isVidPlaying) videoElement.current.pause();
266
+ videoStateRef.current.isPlaying = false;
267
+ }
268
+ });
269
+
270
+ // /** stop video playing when gsapDragging is true */
271
+ React.useEffect(() => {
272
+ console.log("current", videoElement.current, gsapDragging);
273
+ if (videoElement.current) {
274
+ if (gsapDragging) {
275
+ videoElement.current.pause();
276
+ videoStateRef.current.isPlaying = false;
277
+ videoStateRef.current.isDragging = true;
278
+ } else {
279
+ videoStateRef.current.isDragging = false;
280
+ }
281
+ }
282
+ }, [gsapDragging]);
283
+
284
+ /** Gsap Start and Stop Events */
285
+ const gsapOnStart = (startAt: number) => {
286
+ if (videoElement.current) {
287
+ console.log("video gsapOnStart", playerTimeRef.current, gsapDragging);
288
+
289
+ // check the start and end times are between the playerTimeRef.current to start video;
290
+ if (
291
+ playerTimeRef.current >= startAt &&
292
+ playerTimeRef.current <= endAt &&
293
+ !gsapDragging
294
+ ) {
295
+ videoElement.current.currentTime =
296
+ Number(frameStartAt) || Number(startAt);
297
+ videoElement.current.play();
298
+ videoStateRef.current.isPlaying = true;
299
+ }
300
+ }
301
+ };
302
+
303
+ const gsapOnPause = (startAt: number) => {
304
+ if (videoElement.current) {
305
+ setVidPlay(false);
306
+
307
+ const vid = videoElement.current;
308
+ const isVidPlaying =
309
+ vid.currentTime > 0 &&
310
+ !vid.paused &&
311
+ !vid.ended &&
312
+ vid.readyState > vid.HAVE_CURRENT_DATA;
313
+ ///if (!isVidPlaying) videoElement.current.play();
314
+ if (isVidPlaying) videoElement.current.pause();
315
+ videoStateRef.current.isPlaying = false;
316
+ }
317
+ };
318
+
319
+ const gsapOnComplete = () => {
320
+ console.log("onComplete triggered");
321
+ if (videoElement.current) {
322
+ setVidPlay(false);
323
+ const vid = videoElement.current;
324
+ const isVidPlaying =
325
+ vid.currentTime > 0 &&
326
+ !vid.paused &&
327
+ !vid.ended &&
328
+ vid.readyState > vid.HAVE_CURRENT_DATA;
329
+ ///if (!isVidPlaying) videoElement.current.play();
330
+ if (isVidPlaying) videoElement.current.pause();
331
+ videoStateRef.current.isPlaying = false;
332
+ }
333
+ };
334
+
335
+ const onInterrupt = () => {
336
+ // console.log('interrupting', refId);
337
+ };
338
+
339
+ const onUpdate = () => {
340
+ if (videoElement.current) {
341
+ // console.log(
342
+ // "currenttime vs player reftime",
343
+ // videoElement.current.currentTime,
344
+ // playerTimeRef.current
345
+ // );
346
+ const absDiff = Math.abs(
347
+ videoElement.current.currentTime - playerTimeRef.current
348
+ );
349
+
350
+ const vid = videoElement.current;
351
+ const isVidPlaying =
352
+ vid.currentTime > 0 &&
353
+ !vid.paused &&
354
+ !vid.ended &&
355
+ vid.readyState > vid.HAVE_CURRENT_DATA;
356
+
357
+ if (videoStateRef.current.isDragging) {
358
+ console.log("video updating", playerTimeRef.current);
359
+ videoElement.current.currentTime = playerTimeRef.current;
360
+ videoElement.current.play();
361
+ setTimeout(() => {
362
+ videoStateRef.current.isPlaying = false;
363
+ if (videoElement.current) videoElement.current.pause();
364
+ }, 55);
365
+ videoStateRef.current.isPlaying = false;
366
+ } else if (!videoStateRef.current.isPlaying) {
367
+ // if (!isVidPlaying) videoElement.current.play();
368
+ // videoStateRef.current.isPlaying = true;
369
+ // let the video play and update current time
370
+ // videoElement.current.currentTime = playerTimeRef.current;
371
+ if (!isVidPlaying) videoElement.current.play();
372
+ videoStateRef.current.isPlaying = true;
373
+ } else if (absDiff > 0.3) {
374
+ // videoElement.current.currentTime = playerTimeRef.current;
375
+ // if (!isVidPlaying) videoElement.current.play();
376
+ // videoStateRef.current.isPlaying = true;
377
+ }
378
+ }
379
+ };
380
+
381
+ const handleComplete = () => {
382
+ // if (onComplete) {
383
+ // onComplete();
384
+ // }
385
+ videoStateRef.current.isPlaying = false;
386
+ };
387
+
388
+ useEffect(() => {
389
+ let ctx = gsap.context(() => {});
390
+ if (containerRef.current && tl.current) {
391
+ const data = {
392
+ duration: Number(endAt) - Number(startAt),
393
+ onStart: gsapOnStart,
394
+ onComplete: gsapOnComplete,
395
+ onStartParams: [startAt],
396
+ onCompleteParams: [],
397
+ onInterrupt: onInterrupt,
398
+ onUpdate: onUpdate,
399
+ onUpdateParams: [],
400
+ };
401
+
402
+ const ease = getAnimByName(animation || "None");
403
+ ctx = gsap.context(() => {
404
+ if (!isEmpty(ease.from)) {
405
+ tl.current
406
+ .from(containerRef.current, { ...ease.from }, startAt)
407
+ .to(imgGroupRef.current, { alpha: 1, duration: 0.2 }, startAt)
408
+ .from(imgGroupRef.current, { ...data }, startAt)
409
+ .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
410
+ } else if (!isEmpty(ease.to)) {
411
+ tl.current
412
+ .to(
413
+ containerRef.current,
414
+ { alpha: 1, duration: 0.2, ...ease.to },
415
+ startAt
416
+ )
417
+ .from(imgGroupRef.current, { ...data }, startAt)
418
+ .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
419
+ } else if (!isEmpty(ease.fromTo)) {
420
+ tl.current
421
+ .fromTo(
422
+ containerRef.current,
423
+ ease.fromTo?.from,
424
+ ease.fromTo?.to,
425
+ startAt
426
+ )
427
+ .from(imgGroupRef.current, { ...data }, startAt)
428
+ .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
429
+ } else {
430
+ tl.current
431
+ .to(containerRef.current, { alpha: 1, duration: 0.01 }, startAt)
432
+ .from(imgGroupRef.current, { ...data }, startAt)
433
+ .to(
434
+ containerRef.current,
435
+ { alpha: 0, duration: 0.1 },
436
+ Number(endAt) - Number(0.1)
437
+ );
438
+ }
439
+ });
440
+ }
441
+ return () => ctx.revert(); // cleanup!
442
+ }, [animation, startAt, endAt]);
443
+
444
+ React.useEffect(() => {
445
+ if (containerRef.current) {
446
+ setIsMounted(true);
447
+ }
448
+ }, []);
449
+
450
+ React.useEffect(() => {
451
+ if (videoElement.current) {
452
+ videoElement.current.muted = mute;
453
+ }
454
+ }, [mute]);
455
+
456
+ // stop playing video while isDragging and gsapDragging
457
+ React.useEffect(() => {
458
+ if (videoElement.current) {
459
+ const vid = videoElement.current;
460
+ const isVidPlaying =
461
+ vid.currentTime > 0 &&
462
+ !vid.paused &&
463
+ !vid.ended &&
464
+ vid.readyState > vid.HAVE_CURRENT_DATA;
465
+ if (isVidPlaying && (isDragging || gsapDragging)) {
466
+ videoElement.current.pause();
467
+ videoStateRef.current.isPlaying = false;
468
+ }
469
+ }
470
+ }, [isDragging, gsapDragging]);
471
+
472
+ // load // load meta // load seek through
473
+ React.useEffect(() => {
474
+ const minStartAt =
475
+ Math.round((Number(frameStartAt) + Number.EPSILON) * 100) / 100;
476
+ const onload = function () {
477
+ if (videoElement.current) {
478
+ videoElement.current.currentTime = minStartAt;
479
+ }
480
+ };
481
+
482
+ const onEnd = function () {
483
+ //dispatchState({ isPlaying: false });
484
+ if (videoElement.current) {
485
+ const vid = videoElement.current;
486
+ const isVidPlaying =
487
+ vid.currentTime > 0 &&
488
+ !vid.paused &&
489
+ !vid.ended &&
490
+ vid.readyState > vid.HAVE_CURRENT_DATA;
491
+
492
+ if (isVidPlaying) {
493
+ videoElement.current.pause();
494
+ }
495
+ }
496
+ setVideoState({ isWaiting: false, isStalled: false });
497
+ };
498
+
499
+ const onLoadStart = function () {
500
+ //dispatchState({ isWaiting: true, isStalled: false });
501
+ if (videoElement.current) {
502
+ videoElement.current.pause();
503
+ }
504
+ setVideoState({ isWaiting: true, isStalled: false });
505
+ };
506
+
507
+ const onCanPlayThrough = function () {
508
+ //dispatchState({ isWaiting: false, isStalled: false });
509
+ setVideoState({ isWaiting: false, isStalled: false });
510
+ };
511
+
512
+ const onStalled = function () {
513
+ //dispatchState({ isStalled: true });
514
+ setVideoState({ isWaiting: false, isStalled: true });
515
+ };
516
+
517
+ // create a new Sprite using the video texture (yes it's that easy)
518
+ const stAt =
519
+ Math.round((Number(frameStartAt) + Number.EPSILON) * 100) / 100;
520
+ const endAt = Math.round((Number(frameEndAt) + Number.EPSILON) * 100) / 100;
521
+ const urlWithTimestamp = `${videoUrl}#t=${stAt},${endAt}`;
522
+ const urlWithQuery = `${videoUrl}?t=${stAt},${endAt}`;
523
+
524
+ console.log("urlTimestap", urlWithTimestamp);
525
+ /// const texture =
526
+ PIXI.Texture.fromLoader(videoSrcElement, urlWithTimestamp, uniqueId, {
527
+ pixiIdPrefix: uniqueId,
528
+ resourceOptions: {
529
+ autoPlay: false,
530
+ crossorigin: "Anonymus",
531
+ updateFPS: 30,
532
+ },
533
+ }).then((texture) => {
534
+ if (!texture) return;
535
+ // texture.baseTexture.resource.source.currentSrc = urlWithTimestamp;
536
+ setVideoTexture(texture);
537
+ // @ts-ignore
538
+ console.log(texture.baseTexture.resource.source);
539
+ // @ts-ignore
540
+ videoElement.current = texture.baseTexture.resource.source;
541
+ // @ts-ignore
542
+ videoElement.current.id = uniqueId;
543
+ // @ts-ignore
544
+ videoElement.current.addEventListener("loadedmetadata", onload);
545
+ // @ts-ignore
546
+ videoElement.current.addEventListener("ended", onEnd);
547
+ // @ts-ignore
548
+ videoElement.current.addEventListener("loadstart", onLoadStart);
549
+ // @ts-ignore
550
+ videoElement.current.addEventListener("canplaythrough", onCanPlayThrough);
551
+ // @ts-ignore
552
+ videoElement.current.addEventListener("stalled", onStalled);
553
+ });
554
+
555
+ return () => {
556
+ // @ts-ignore
557
+ videoElement.current.removeEventListener("loadedmetadata", onload);
558
+ // @ts-ignore
559
+ videoElement.current.removeEventListener("ended", onEnd);
560
+ // @ts-ignore
561
+ videoElement.current.removeEventListener("loadstart", onLoadStart);
562
+ // @ts-ignore
563
+ videoElement.current.removeEventListener(
564
+ "canplaythrough",
565
+ onCanPlayThrough
566
+ );
567
+ // @ts-ignore
568
+ videoElement.current.removeEventListener("stalled", onStalled);
569
+ };
570
+ // create a new Sprite using the video texture (yes it's that easy)
571
+ // const videoSprite = new PIXI.Sprite(texture);
572
+ }, [videoUrl, uniqueId, frameStartAt, frameEndAt, videoSrcElement]);
573
+
574
+ return (
575
+ // @ts-ignore
576
+ <Container ref={parentNode}>
577
+ {/* @ts-ignore */}
578
+ {/* @ts-ignore */}
579
+ <Container
580
+ ref={containerRef}
581
+ alpha={initialAlpha}
582
+ position={[x, y]}
583
+ pivot={[x, y]}
584
+ width={width}
585
+ height={height}
586
+ >
587
+ {colorCorrection && colorCorrection.enabled ? (
588
+ <Filters
589
+ scale={1}
590
+ blur={{ blur: blurRadius, quality: 4 }}
591
+ adjust={adjustments}
592
+ apply={({ matrix }: { matrix: any }) => {
593
+ if (effect === "BlackAndWhite") {
594
+ matrix.desaturate();
595
+ } else if (effect === "Sepia") {
596
+ matrix.sepia();
597
+ } else if (effect === "RetroVintage") {
598
+ matrix.negative();
599
+ } else if (effect === "NightVision") {
600
+ matrix.negative();
601
+ } else if (effect === "Normal") {
602
+ matrix.reset();
603
+ }
604
+ }}
605
+ matrix={{
606
+ enabled: true,
607
+ // @ts-ignore
608
+ matrix: CYAN,
609
+ }}
610
+ >
611
+ {/* @ts-ignore */}
612
+ <Container ref={imgGroupRef}>
613
+ {videoTexture && (
614
+ <Sprite
615
+ texture={videoTexture}
616
+ width={width}
617
+ height={height}
618
+ anchor={0.5}
619
+ x={x}
620
+ y={y}
621
+ {...(!locked &&
622
+ !isDragging && {
623
+ interactive: true,
624
+ buttonMode: true,
625
+ pointerdown: pointerdown,
626
+ pointerover: pointerover,
627
+ pointerout: mouseout,
628
+ mousedown: mousedown,
629
+ mouseover: mouseover,
630
+ mouseout: mouseout,
631
+ })}
632
+ ref={imageRef}
633
+ scale={scale}
634
+ rotation={rotation}
635
+ />
636
+ )}
637
+ </Container>
638
+ </Filters>
639
+ ) : (
640
+ // @ts-ignore
641
+ <Container ref={imgGroupRef}>
642
+ {videoTexture && (
643
+ <Sprite
644
+ texture={videoTexture}
645
+ width={width}
646
+ height={height}
647
+ anchor={0.5}
648
+ x={x}
649
+ y={y}
650
+ {...(!locked &&
651
+ !isDragging && {
652
+ interactive: true,
653
+ buttonMode: true,
654
+ pointerdown: pointerdown,
655
+ pointerover: pointerover,
656
+ pointerout: mouseout,
657
+ mousedown: mousedown,
658
+ mouseover: mouseover,
659
+ mouseout: mouseout,
660
+ })}
661
+ ref={imageRef}
662
+ scale={scale}
663
+ rotation={rotation}
664
+ />
665
+ )}
666
+ </Container>
667
+ )}
668
+ </Container>
669
+ {applyTransformer && (
670
+ <PixiTransformer
671
+ pixiTransformerRef={transformerRef}
672
+ imageRef={containerRef}
673
+ isMounted={isMounted}
674
+ transformCommit={handleOnTransformEnd}
675
+ transformChange={handleOnTransformChange}
676
+ mouseoverEvent={setIsMouseOverTransformer}
677
+ uniqueId={uniqueId}
678
+ />
679
+ )}
680
+ </Container>
681
+ );
682
+ };
683
+
684
+ export default PixiVideoSprite;