reacthub-pixitweenjs 0.2.4 → 0.2.6

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 (40) hide show
  1. package/.storybook/preview.tsx +6 -0
  2. package/CHANGELOG.md +27 -0
  3. package/README.md +1 -1
  4. package/build-storybook.log +79 -476
  5. package/package.json +29 -29
  6. package/src/components/PixiAnimatedSprite/PixiAnimatedSprite.tsx +51 -0
  7. package/src/components/PixiAnimatedSprite/index.ts +2 -0
  8. package/src/components/PixiAudioSprite/PixiAudioSprite.stories.tsx +61 -0
  9. package/src/components/PixiAudioSprite/PixiAudioSprite.tsx +202 -0
  10. package/src/components/PixiAudioSprite/index.ts +1 -0
  11. package/src/components/PixiGifSprite/PixiGifSprite.stories.tsx +135 -0
  12. package/src/components/PixiGifSprite/PixiGifSprite.tsx +372 -0
  13. package/src/components/PixiGifSprite/index.ts +2 -0
  14. package/src/components/PixiImageSprite/PixiImageSprite.stories.tsx +11 -0
  15. package/src/components/PixiImageSprite/PixiImageSprite.tsx +33 -70
  16. package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +137 -0
  17. package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +346 -0
  18. package/src/components/PixiSVGSprite/index.ts +1 -0
  19. package/src/components/PixiTextSprite/PixiTextSprite.stories.tsx +176 -0
  20. package/src/components/PixiTextSprite/PixiTextSprite.tsx +540 -0
  21. package/src/components/PixiTextSprite/index.ts +1 -0
  22. package/src/components/PixiVideoSprite/PixiVideoSprite.stories.tsx +147 -0
  23. package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +631 -0
  24. package/src/components/PixiVideoSprite/PixiVideoSpriteBackup.txt +755 -0
  25. package/src/components/PixiVideoSprite/index.ts +1 -0
  26. package/src/declare.module.ts +5 -0
  27. package/src/main.tsx +8 -7
  28. package/src/providers/GsapPixieContextProvider.tsx +102 -22
  29. package/src/reacthub-react-bindings.d.ts +27 -0
  30. package/src/stories/Installation.mdx +3 -3
  31. package/src/utils/AppStateProvider.tsx +18 -29
  32. package/src/utils/AppStateStage.tsx +1 -13
  33. package/src/utils/AppWrapper.tsx +4 -0
  34. package/src/utils/GsapAnim.tsx +1 -7
  35. package/src/utils/InteractionManager.tsx +36 -0
  36. package/src/utils/PixiStage.tsx +1 -5
  37. package/src/utils/PixiTransformer.tsx +165 -0
  38. package/src/utils/VideoSeekBar.tsx +35 -31
  39. package/src/utils/useDebounce.tsx +15 -0
  40. package/src/hooks/usePixiTransformer.tsx +0 -168
@@ -0,0 +1,372 @@
1
+ import * as React from "react";
2
+ import { useContext, useEffect, useRef, useState } from "react";
3
+ // @ts-ignore
4
+ import map from "lodash/map";
5
+ // @ts-ignore
6
+ import PropTypes from "prop-types";
7
+ import { GsapPixieContext } from "../../providers/GsapPixieContextProvider";
8
+ import { Container, useApp, Graphics } from "@pixi/react";
9
+ import * as PIXI from "pixi.js";
10
+ import gsap from "gsap";
11
+ import { useWorkerParser, usePlayerState } from "@react-gifs/tools";
12
+ import PixiTransformer from "../../utils/PixiTransformer";
13
+
14
+ // @ts-ignore
15
+ import isEmpty from "lodash/isEmpty";
16
+ import { getAnimByName } from "../../utils/GsapAnim";
17
+ import { TransformationEnd } from "../../types/transformation";
18
+ import { PixiAnimatedSprite } from "../PixiAnimatedSprite";
19
+
20
+ type PixiGifSpriteProps = {
21
+ uniqueId: string;
22
+ src: string;
23
+ startAt: number;
24
+ endAt: number;
25
+ initialAlpha: number;
26
+ locked: boolean;
27
+ loop: boolean;
28
+ transformation: {
29
+ x: number;
30
+ y: number;
31
+ width: number;
32
+ height: number;
33
+ anchor: number;
34
+ rotation?: number;
35
+ alpha?: number;
36
+ scale?: number | [number, number];
37
+ tint?: number;
38
+ blendMode?: number;
39
+ animation?: string;
40
+ colorCorrection?: {
41
+ enabled?: boolean;
42
+ temperature?: number;
43
+ hue?: number;
44
+ contrast?: number;
45
+ saturation?: number;
46
+ exposure?: number;
47
+ reset?: boolean;
48
+ sharpness?: number;
49
+ value?: number;
50
+ levels?: number;
51
+ luminance?: number;
52
+ enhance?: number;
53
+ blurRadius?: number;
54
+ red?: number;
55
+ green?: number;
56
+ blue?: number;
57
+ alpha?: number;
58
+ scaleInput?: number;
59
+ };
60
+ effect?: string;
61
+ };
62
+ pointerdown?: () => void;
63
+ pointerup?: () => void;
64
+ mousedown?: () => void;
65
+ mouseup?: () => void;
66
+ pointerover?: () => void;
67
+ mouseover?: () => void;
68
+ mouseout?: () => void;
69
+ pointerout?: () => void;
70
+ applyTransformer?: boolean;
71
+ onAnchorTransformationEnd?: (endData: any) => void;
72
+ };
73
+
74
+ /**
75
+ * PixiGifSprite Component is used to render gif image
76
+ * @param props Gif Sprite props
77
+ * @returns
78
+ */
79
+ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
80
+ //// State
81
+ const [gifFrame, setGifFrame] = React.useState<PIXI.Texture[]>([]);
82
+ const [gifDuration, setGifDuration] = React.useState<number>(0);
83
+ const [gifFrameObject, setGifFrameObject] = React.useState<
84
+ PIXI.FrameObject[]
85
+ >([]);
86
+ const [, setCurrentFrame] = useState<number>(0);
87
+ const [, setIsComplete] = useState<boolean>(false);
88
+
89
+ const [isDragging, setIsDragging] = useState(false);
90
+ const [, setIsMouseOverTransformer] = useState(false);
91
+
92
+ const [gifState, update] = usePlayerState({ autoPlay: false });
93
+ const graphicRef = React.useRef<PIXI.Graphics>(null);
94
+
95
+ console.log("allProps", props);
96
+ //// Refs
97
+ const animatedSpriteRef = useRef<PIXI.AnimatedSprite>(null);
98
+ const containerRef = useRef<PIXI.Container>(null);
99
+ const parentNode = useRef<PIXI.Container>(null);
100
+ const imgGroupRef = useRef<PIXI.Container>(null);
101
+ const transformerRef = useRef<PIXI.Container>(null);
102
+
103
+ //// Context
104
+ const { tl, play: tlPlay } = useContext(GsapPixieContext);
105
+
106
+ /// 1001
107
+ console.log("contxt Values", tl);
108
+ console.log("gifState", gifState, gifDuration);
109
+ const { frames: gifFrames, delays: gifDelays, loaded } = gifState;
110
+
111
+ const {
112
+ uniqueId,
113
+ src,
114
+ startAt,
115
+ endAt,
116
+ initialAlpha,
117
+ locked,
118
+ loop,
119
+ transformation: {
120
+ width = 0,
121
+ height = 0,
122
+ x,
123
+ y,
124
+ rotation = 0,
125
+ scale,
126
+ animation,
127
+ },
128
+ pointerdown,
129
+ pointerup,
130
+ mousedown,
131
+ mouseup,
132
+ pointerover,
133
+ mouseover,
134
+ mouseout,
135
+ pointerout,
136
+ applyTransformer,
137
+ onAnchorTransformationEnd,
138
+ } = props;
139
+
140
+ // color corrections
141
+
142
+ const app = useApp();
143
+
144
+ // load and parse gif
145
+ useWorkerParser(src, update);
146
+
147
+ // updates current index
148
+ // usePlayback(gifState, () => update(({ index }) => ({ index: index + 1 })));
149
+
150
+ // transformer to handle sprite transformation
151
+ const handleOnTransformEnd = React.useCallback(
152
+ (endData: TransformationEnd) => {
153
+ console.log("changeEnd", endData);
154
+ if (onAnchorTransformationEnd) {
155
+ onAnchorTransformationEnd(endData);
156
+ }
157
+ },
158
+ []
159
+ );
160
+
161
+ React.useEffect(() => {
162
+ if (!isEmpty(gifFrames)) {
163
+ // app.stage.addChild(frames);
164
+ /// load textues
165
+ const texturedFrames = map(gifFrames, (eachFrame: ImageData) => {
166
+ const { data, width, height } = eachFrame;
167
+ const dataEx = new Uint8Array(data);
168
+ return PIXI.Texture.fromBuffer(dataEx, width, height);
169
+ });
170
+
171
+ const frameObj = texturedFrames.map(
172
+ (eachFrame: PIXI.Texture, index: number) => {
173
+ return {
174
+ texture: eachFrame,
175
+ time: gifDelays[index],
176
+ };
177
+ }
178
+ );
179
+
180
+ setGifFrame(texturedFrames);
181
+ setGifFrameObject(frameObj);
182
+ let duration = 0;
183
+ gifDelays.forEach((delay) => {
184
+ duration += delay * 10;
185
+ });
186
+ setGifDuration(duration);
187
+ }
188
+ }, [gifFrames, gifDelays]);
189
+
190
+ /** Gsap Start and Stop Events */
191
+ const gsapOnStart = (startAt: number) => {
192
+ if (animatedSpriteRef.current) {
193
+ animatedSpriteRef.current.gotoAndPlay(startAt || 0);
194
+ }
195
+ };
196
+
197
+ const gsapOnComplete = () => {
198
+ if (animatedSpriteRef.current) {
199
+ animatedSpriteRef.current.stop();
200
+ // animatedSpriteRef.current.gotoAndStop(0);
201
+ }
202
+ };
203
+
204
+ const onInterrupt = () => {
205
+ // console.log('interrupting', refId);
206
+ };
207
+
208
+ const onUpdate = () => {
209
+ // console.log('timeline paused', ctxTimeLine.paused());
210
+ // if (animatedSpriteRef.current) {
211
+ // animatedSpriteRef.current.play();
212
+ // dispatchState({
213
+ // play: play,
214
+ // });
215
+ // }
216
+ };
217
+
218
+ const handleComplete = () => {
219
+ setIsComplete(true);
220
+ // if (onComplete) {
221
+ // onComplete();
222
+ // }
223
+ };
224
+
225
+ useEffect(() => {
226
+ let ctx = gsap.context(() => {});
227
+ if (containerRef.current && tl.current) {
228
+ const data = {
229
+ duration: Number(endAt) - Number(startAt),
230
+ onStart: gsapOnStart,
231
+ onComplete: gsapOnComplete,
232
+ onStartParams: [startAt],
233
+ onCompleteParams: [],
234
+ onInterrupt: onInterrupt,
235
+ onUpdate: onUpdate,
236
+ onUpdateParams: [],
237
+ };
238
+
239
+ const ease = getAnimByName(animation || "None");
240
+ ctx = gsap.context(() => {
241
+ if (!isEmpty(ease.from)) {
242
+ tl.current
243
+ .from(containerRef.current, { ...ease.from }, startAt)
244
+ .to(imgGroupRef.current, { alpha: 1, duration: 0.2 }, startAt)
245
+ .from(imgGroupRef.current, { ...data }, startAt)
246
+ .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
247
+ } else if (!isEmpty(ease.to)) {
248
+ tl.current
249
+ .to(
250
+ containerRef.current,
251
+ { alpha: 1, duration: 0.2, ...ease.to },
252
+ startAt
253
+ )
254
+ .from(imgGroupRef.current, { ...data }, startAt)
255
+ .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
256
+ } else if (!isEmpty(ease.fromTo)) {
257
+ tl.current
258
+ .fromTo(
259
+ containerRef.current,
260
+ ease.fromTo?.from,
261
+ ease.fromTo?.to,
262
+ startAt
263
+ )
264
+ .from(imgGroupRef.current, { ...data }, startAt)
265
+ .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
266
+ } else {
267
+ tl.current
268
+ .to(containerRef.current, { alpha: 1, duration: 0.01 }, startAt)
269
+ .from(imgGroupRef.current, { ...data }, startAt)
270
+ .to(
271
+ containerRef.current,
272
+ { alpha: 0, duration: 0.1 },
273
+ Number(endAt) - Number(0.1)
274
+ );
275
+ }
276
+ });
277
+ }
278
+ return () => ctx.revert(); // cleanup!
279
+ }, [animation, startAt, endAt]);
280
+
281
+ /** handle on tranformer onchange */
282
+ const handleOnTransformChange = React.useCallback(() => {
283
+ setIsDragging(true);
284
+ }, []);
285
+
286
+ app.ticker.add((delta) => {
287
+ if (graphicRef.current) {
288
+ graphicRef.current.rotation += 0.01 * delta;
289
+ graphicRef.current
290
+ .clear()
291
+ .lineStyle(4, 0xffffff, 1)
292
+ .moveTo(40, 0)
293
+ .arc(0, 0, 40, 0, Math.PI * 2 * 0.6, false);
294
+ }
295
+ });
296
+
297
+ const draw = React.useCallback((g: PIXI.Graphics) => {
298
+ g.clear();
299
+ }, []);
300
+
301
+ return (
302
+ // @ts-ignore
303
+ <Container ref={parentNode}>
304
+ {/* @ts-ignore */}
305
+ <Container
306
+ ref={containerRef}
307
+ alpha={initialAlpha}
308
+ position={[x, y]}
309
+ pivot={[x, y]}
310
+ width={width}
311
+ height={height}
312
+ >
313
+ {/* @ts-ignore */}
314
+ <Container ref={imgGroupRef}>
315
+ {!loaded && (
316
+ // @ts-ignore
317
+ <Container anchor={0.5} position={[width / 2, height / 2]}>
318
+ <Graphics x={x} y={y} ref={graphicRef} draw={draw} />
319
+ </Container>
320
+ )}
321
+ {gifFrame && gifFrame.length > 0 && (
322
+ <PixiAnimatedSprite
323
+ x={x}
324
+ y={y}
325
+ width={width}
326
+ height={height}
327
+ rotation={rotation}
328
+ animationSpeed={1}
329
+ loop={loop}
330
+ isPlaying={!!tlPlay}
331
+ // @ts-ignore
332
+ textures={gifFrameObject}
333
+ onComplete={handleComplete}
334
+ onFrameChange={(currentFrame: number) =>
335
+ setCurrentFrame(currentFrame)
336
+ }
337
+ anchor={0.5}
338
+ {...(!locked &&
339
+ !isDragging && {
340
+ interactive: true,
341
+ buttonMode: true,
342
+ pointerdown: pointerdown,
343
+ pointerover: pointerover,
344
+ pointerout: pointerout,
345
+ pointerup: pointerup,
346
+ mousedown: mousedown,
347
+ mouseup: mouseup,
348
+ mouseover: mouseover,
349
+ mouseout: mouseout,
350
+ })}
351
+ forwardRef={animatedSpriteRef}
352
+ scale={scale}
353
+ />
354
+ )}
355
+ </Container>
356
+ </Container>
357
+ {applyTransformer && (
358
+ <PixiTransformer
359
+ pixiTransformerRef={transformerRef}
360
+ imageRef={containerRef}
361
+ isMounted={loaded}
362
+ transformCommit={handleOnTransformEnd}
363
+ transformChange={handleOnTransformChange}
364
+ mouseoverEvent={setIsMouseOverTransformer}
365
+ uniqueId={uniqueId}
366
+ />
367
+ )}
368
+ </Container>
369
+ );
370
+ };
371
+
372
+ export default PixiGifSprite;
@@ -0,0 +1,2 @@
1
+ export { default as PixiGifSprite } from "./PixiGifSprite";
2
+ export * from "./PixiGifSprite";
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { PixiImageSprite } from ".";
3
+ import { AppStateContextProvider } from "../../utils/AppStateProvider";
3
4
 
4
5
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
5
6
  const meta = {
@@ -75,6 +76,11 @@ type Story = StoryObj<typeof meta>;
75
76
 
76
77
  // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
77
78
  export const Normal: Story = {
79
+ render: (args: any) => (
80
+ <AppStateContextProvider {...args}>
81
+ <PixiImageSprite {...args} />
82
+ </AppStateContextProvider>
83
+ ),
78
84
  args: {
79
85
  uniqueId: "surya001", // uniqueId of the sprite
80
86
  src: "https://assets.codepen.io/693612/surya.svg",
@@ -99,6 +105,11 @@ export const Normal: Story = {
99
105
  };
100
106
 
101
107
  export const FadeIn: Story = {
108
+ render: (args: any) => (
109
+ <AppStateContextProvider {...args}>
110
+ <PixiImageSprite {...args} />
111
+ </AppStateContextProvider>
112
+ ),
102
113
  args: {
103
114
  uniqueId: "surya002", // uniqueId of the sprite
104
115
  src: "https://assets.codepen.io/693612/surya.svg",
@@ -3,14 +3,15 @@ import { useContext, useEffect, useRef, useState } from "react";
3
3
  // @ts-ignore
4
4
  import PropTypes from "prop-types";
5
5
  import { GsapPixieContext } from "../../providers/GsapPixieContextProvider";
6
- import { Sprite, Container, useApp, withFilters } from "@pixi/react";
6
+ import { Sprite, Container, withFilters } from "@pixi/react";
7
7
  import { AdjustmentFilter } from "@pixi/filter-adjustment";
8
8
  import * as PIXI from "pixi.js";
9
9
  import gsap from "gsap";
10
+ import PixiTransformer from "../../utils/PixiTransformer";
11
+
10
12
  // @ts-ignore
11
13
  import isEmpty from "lodash/isEmpty";
12
14
  import { getAnimByName } from "../../utils/GsapAnim";
13
- import { usePixiTransformer } from "../../hooks/usePixiTransformer";
14
15
  import { TransformationEnd } from "../../types/transformation";
15
16
 
16
17
  type PixiImageSpriteProps = {
@@ -64,41 +65,20 @@ type PixiImageSpriteProps = {
64
65
  onAnchorTransformationEnd?: (endData: any) => void;
65
66
  };
66
67
 
67
- type EffectFunc = () => void;
68
- type Deps = ReadonlyArray<unknown>;
69
-
70
68
  const Filters = withFilters(Container, {
71
69
  blur: PIXI.filters.BlurFilter,
72
70
  adjust: AdjustmentFilter,
73
71
  matrix: PIXI.filters.ColorMatrixFilter,
74
72
  });
75
73
 
76
- /** filter config */
77
- const config = {
78
- dot: {
79
- scale: 1,
80
- angle: 5,
81
- },
82
- blur: {
83
- blur: 0,
84
- quality: 4,
85
- },
86
- };
87
-
88
74
  /** CYAN Filters */
89
75
  const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
90
76
 
91
77
  const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
92
78
  //// State
93
- const [transform, setTransform] = useState({
94
- x: 0,
95
- y: 0,
96
- width: 80,
97
- height: 80,
98
- rotate: 0,
99
- });
100
- const [isTransformerDragging, setIsTransformerDragging] = useState(false);
101
- const [isMouseOverTransformer, setIsMouseOverTransformer] = useState(false);
79
+ const [isMounted, setIsMounted] = React.useState(false);
80
+ const [, setIsTransformerDragging] = useState(false);
81
+ const [, setIsMouseOverTransformer] = useState(false);
102
82
 
103
83
  console.log("allProps", props);
104
84
  //// Refs
@@ -106,12 +86,13 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
106
86
  const containerRef = useRef<PIXI.Container>(null);
107
87
  const parentNode = useRef<PIXI.Container>(null);
108
88
  const imgGroupRef = useRef<PIXI.Container>(null);
89
+ const transformerRef = useRef<PIXI.Container>(null);
109
90
 
110
91
  //// Context
111
92
  const { tl } = useContext(GsapPixieContext);
112
93
 
113
94
  /// 1001
114
- console.log("contxt Values", tl);
95
+ // console.log("contxt Values", tl);
115
96
  const {
116
97
  uniqueId,
117
98
  src,
@@ -137,34 +118,17 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
137
118
  mouseout,
138
119
  applyTransformer,
139
120
  onAnchorTransformationEnd,
140
- ...restProps
141
121
  } = props;
142
122
 
143
123
  // color corrections
144
124
  const {
145
- enabled = false,
146
- temperature = 1,
147
- hue = 1,
148
125
  contrast = 1,
149
126
  saturation = 1,
150
127
  exposure = 1,
151
- reset,
152
- sharpness = 1,
153
- value = 0,
154
- levels = 1,
155
- luminance = 0,
156
- enhance = 0,
157
128
  blurRadius = 0,
158
- red = 150,
159
- green = 150,
160
- blue = 150,
161
129
  alpha = 1,
162
- scaleInput = 1,
163
130
  } = colorCorrection || {};
164
131
 
165
- const app = useApp();
166
- const PixiTransformer = useRef<any>(null);
167
-
168
132
  /** adjustment filter */
169
133
  const adjustments = {
170
134
  brightness: exposure,
@@ -173,27 +137,23 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
173
137
  alpha,
174
138
  };
175
139
 
140
+ /** handle on tranformer onchange */
141
+ const handleOnTransformChange = React.useCallback(() => {
142
+ setIsTransformerDragging(true);
143
+ }, []);
144
+
176
145
  // transformer to handle sprite transformation
177
146
  const handleOnTransformEnd = React.useCallback(
178
147
  (endData: TransformationEnd) => {
179
148
  console.log("changeEnd", endData);
180
149
  if (onAnchorTransformationEnd) {
150
+ console.log("running onAnchorTransformationEnd");
181
151
  onAnchorTransformationEnd(endData);
182
152
  }
183
153
  },
184
- [],
154
+ []
185
155
  );
186
156
 
187
- // initialize usePixiTransformer hook
188
- const { handleTransformer, removeTransformer, isDragging } =
189
- usePixiTransformer({
190
- uniqueId,
191
- onTransformEnd: handleOnTransformEnd,
192
- events: {},
193
- mouseoverEvent: setIsMouseOverTransformer,
194
- setDragging: setIsTransformerDragging,
195
- });
196
-
197
157
  useEffect(() => {
198
158
  let ctx = gsap.context(() => {});
199
159
  if (containerRef.current && tl.current) {
@@ -214,7 +174,7 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
214
174
  .to(
215
175
  containerRef.current,
216
176
  { alpha: 1, duration: 0.2, ...ease.to },
217
- startAt,
177
+ startAt
218
178
  )
219
179
  .from(imgGroupRef.current, { ...data }, startAt)
220
180
  .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
@@ -224,7 +184,7 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
224
184
  containerRef.current,
225
185
  ease.fromTo?.from,
226
186
  ease.fromTo?.to,
227
- startAt,
187
+ startAt
228
188
  )
229
189
  .from(imgGroupRef.current, { ...data }, startAt)
230
190
  .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
@@ -235,7 +195,7 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
235
195
  .to(
236
196
  containerRef.current,
237
197
  { alpha: 0, duration: 0.1 },
238
- Number(endAt) - Number(0.1),
198
+ Number(endAt) - Number(0.1)
239
199
  );
240
200
  }
241
201
  });
@@ -243,19 +203,11 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
243
203
  return () => ctx.revert(); // cleanup!
244
204
  }, [animation, startAt, endAt]);
245
205
 
246
- useEffect(() => {
247
- setIsTransformerDragging(isDragging);
248
- }, [isDragging]);
249
-
250
- // apply transformer in use effect hook based on prop applyTransformer
251
- useEffect(() => {
252
- if (applyTransformer && containerRef.current && parentNode.current) {
253
- handleTransformer(containerRef.current, parentNode.current);
206
+ React.useEffect(() => {
207
+ if (containerRef.current) {
208
+ setIsMounted(true);
254
209
  }
255
- return () => {
256
- removeTransformer();
257
- };
258
- }, [removeTransformer, handleTransformer, applyTransformer]);
210
+ }, []);
259
211
 
260
212
  return (
261
213
  // @ts-ignore
@@ -339,6 +291,17 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
339
291
  </Container>
340
292
  )}
341
293
  </Container>
294
+ {applyTransformer && (
295
+ <PixiTransformer
296
+ pixiTransformerRef={transformerRef}
297
+ imageRef={containerRef}
298
+ isMounted={isMounted}
299
+ transformCommit={handleOnTransformEnd}
300
+ transformChange={handleOnTransformChange}
301
+ mouseoverEvent={setIsMouseOverTransformer}
302
+ uniqueId={uniqueId}
303
+ />
304
+ )}
342
305
  </Container>
343
306
  );
344
307
  };