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