reacthub-pixitweenjs 0.2.6 → 0.2.7
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 +13 -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 +53 -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/hocs/AbstractContainer.tsx +199 -0
- package/src/hocs/WithFilterContainer.tsx +159 -0
- 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 +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.2.7](https://github.com/khanzzirfan/reacthub-pixitweenjs/compare/v0.2.6...v0.2.7) (2023-08-27)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* reupdated the filters and hoc wrappers ([0083847](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/00838477793b342453341f1dbd3e418c66f02619))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* filters applied on all video and other elements ([19100d0](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/19100d0f16d7f7be4ad0f4622a1b9f67765b3134))
|
|
16
|
+
* pixi fixed colorization component ([8ca4c32](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/8ca4c326514eb6c677c1460323afe92c34c25060))
|
|
17
|
+
|
|
5
18
|
### [0.2.6](https://github.com/khanzzirfan/reacthub-pixitweenjs/compare/v0.2.5...v0.2.6) (2023-08-25)
|
|
6
19
|
|
|
7
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reacthub-pixitweenjs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "reacthub-pixitweenjs is a library that provides a powerful combination of React, PixiJS, GSAP, and image manipulation capabilities in a timeline sequence. With this library, you can easily create stunning animations and interactive graphics for your React applications",
|
|
5
5
|
"author": "khanzzirfan",
|
|
6
6
|
"type": "module",
|
|
@@ -114,11 +114,14 @@ export const Normal: Story = {
|
|
|
114
114
|
src: "https://media.giphy.com/media/5VKbvrjxpVJCM/giphy.gif",
|
|
115
115
|
locked: false,
|
|
116
116
|
loop: false,
|
|
117
|
+
applyTransformer: false,
|
|
118
|
+
startAt: 0,
|
|
119
|
+
endAt: 4,
|
|
117
120
|
transformation: {
|
|
118
|
-
x:
|
|
119
|
-
y:
|
|
120
|
-
width:
|
|
121
|
-
height:
|
|
121
|
+
x: 200,
|
|
122
|
+
y: 200,
|
|
123
|
+
width: 200,
|
|
124
|
+
height: 200,
|
|
122
125
|
anchor: 0.5,
|
|
123
126
|
rotation: 0,
|
|
124
127
|
alpha: 1,
|
|
@@ -127,9 +130,43 @@ export const Normal: Story = {
|
|
|
127
130
|
blendMode: 0,
|
|
128
131
|
colorCorrection: {},
|
|
129
132
|
},
|
|
133
|
+
initialAlpha: 1,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const Filters: Story = {
|
|
138
|
+
render: (args: any) => (
|
|
139
|
+
<AppStateContextProvider {...args}>
|
|
140
|
+
<PixiGifSprite {...args} />
|
|
141
|
+
</AppStateContextProvider>
|
|
142
|
+
),
|
|
143
|
+
args: {
|
|
144
|
+
uniqueId: "suryaGify001", // uniqueId of the sprite
|
|
145
|
+
src: "https://media.giphy.com/media/5VKbvrjxpVJCM/giphy.gif",
|
|
146
|
+
locked: false,
|
|
147
|
+
loop: false,
|
|
130
148
|
applyTransformer: false,
|
|
131
149
|
startAt: 0,
|
|
132
150
|
endAt: 4,
|
|
151
|
+
transformation: {
|
|
152
|
+
x: 200,
|
|
153
|
+
y: 200,
|
|
154
|
+
width: 200,
|
|
155
|
+
height: 200,
|
|
156
|
+
anchor: 0.5,
|
|
157
|
+
rotation: 0,
|
|
158
|
+
alpha: 1,
|
|
159
|
+
scale: 1,
|
|
160
|
+
tint: 0xffffff,
|
|
161
|
+
blendMode: 0,
|
|
162
|
+
colorCorrection: {
|
|
163
|
+
enabled: true,
|
|
164
|
+
contrast: 2,
|
|
165
|
+
saturation: 2,
|
|
166
|
+
exposure: 2,
|
|
167
|
+
blurRadius: 1,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
133
170
|
initialAlpha: 1,
|
|
134
171
|
},
|
|
135
172
|
};
|
|
@@ -5,7 +5,8 @@ import map from "lodash/map";
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
import PropTypes from "prop-types";
|
|
7
7
|
import { GsapPixieContext } from "../../providers/GsapPixieContextProvider";
|
|
8
|
-
import { Container, useApp, Graphics } from "@pixi/react";
|
|
8
|
+
import { Container, useApp, Graphics, withFilters } from "@pixi/react";
|
|
9
|
+
import { AdjustmentFilter } from "@pixi/filter-adjustment";
|
|
9
10
|
import * as PIXI from "pixi.js";
|
|
10
11
|
import gsap from "gsap";
|
|
11
12
|
import { useWorkerParser, usePlayerState } from "@react-gifs/tools";
|
|
@@ -71,6 +72,15 @@ type PixiGifSpriteProps = {
|
|
|
71
72
|
onAnchorTransformationEnd?: (endData: any) => void;
|
|
72
73
|
};
|
|
73
74
|
|
|
75
|
+
const Filters = withFilters(Container, {
|
|
76
|
+
blur: PIXI.filters.BlurFilter,
|
|
77
|
+
adjust: AdjustmentFilter,
|
|
78
|
+
matrix: PIXI.filters.ColorMatrixFilter,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/** CYAN Filters */
|
|
82
|
+
const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
83
|
+
|
|
74
84
|
/**
|
|
75
85
|
* PixiGifSprite Component is used to render gif image
|
|
76
86
|
* @param props Gif Sprite props
|
|
@@ -79,7 +89,7 @@ type PixiGifSpriteProps = {
|
|
|
79
89
|
const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
80
90
|
//// State
|
|
81
91
|
const [gifFrame, setGifFrame] = React.useState<PIXI.Texture[]>([]);
|
|
82
|
-
const [
|
|
92
|
+
const [, setGifDuration] = React.useState<number>(0);
|
|
83
93
|
const [gifFrameObject, setGifFrameObject] = React.useState<
|
|
84
94
|
PIXI.FrameObject[]
|
|
85
95
|
>([]);
|
|
@@ -92,7 +102,6 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
92
102
|
const [gifState, update] = usePlayerState({ autoPlay: false });
|
|
93
103
|
const graphicRef = React.useRef<PIXI.Graphics>(null);
|
|
94
104
|
|
|
95
|
-
console.log("allProps", props);
|
|
96
105
|
//// Refs
|
|
97
106
|
const animatedSpriteRef = useRef<PIXI.AnimatedSprite>(null);
|
|
98
107
|
const containerRef = useRef<PIXI.Container>(null);
|
|
@@ -104,8 +113,6 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
104
113
|
const { tl, play: tlPlay } = useContext(GsapPixieContext);
|
|
105
114
|
|
|
106
115
|
/// 1001
|
|
107
|
-
console.log("contxt Values", tl);
|
|
108
|
-
console.log("gifState", gifState, gifDuration);
|
|
109
116
|
const { frames: gifFrames, delays: gifDelays, loaded } = gifState;
|
|
110
117
|
|
|
111
118
|
const {
|
|
@@ -124,6 +131,8 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
124
131
|
rotation = 0,
|
|
125
132
|
scale,
|
|
126
133
|
animation,
|
|
134
|
+
colorCorrection,
|
|
135
|
+
effect,
|
|
127
136
|
},
|
|
128
137
|
pointerdown,
|
|
129
138
|
pointerup,
|
|
@@ -138,6 +147,21 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
138
147
|
} = props;
|
|
139
148
|
|
|
140
149
|
// color corrections
|
|
150
|
+
const {
|
|
151
|
+
contrast = 1,
|
|
152
|
+
saturation = 1,
|
|
153
|
+
exposure = 1,
|
|
154
|
+
blurRadius = 0,
|
|
155
|
+
alpha = 1,
|
|
156
|
+
} = colorCorrection || {};
|
|
157
|
+
|
|
158
|
+
/** adjustment filter */
|
|
159
|
+
const adjustments = {
|
|
160
|
+
brightness: exposure,
|
|
161
|
+
contrast,
|
|
162
|
+
saturation,
|
|
163
|
+
alpha,
|
|
164
|
+
};
|
|
141
165
|
|
|
142
166
|
const app = useApp();
|
|
143
167
|
|
|
@@ -319,38 +343,62 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
319
343
|
</Container>
|
|
320
344
|
)}
|
|
321
345
|
{gifFrame && gifFrame.length > 0 && (
|
|
322
|
-
<
|
|
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
|
-
|
|
346
|
+
<Filters
|
|
347
|
+
scale={1}
|
|
348
|
+
blur={{ blur: blurRadius, quality: 4 }}
|
|
349
|
+
adjust={adjustments}
|
|
350
|
+
apply={({ matrix }: { matrix: any }) => {
|
|
351
|
+
if (effect === "BlackAndWhite") {
|
|
352
|
+
matrix.desaturate();
|
|
353
|
+
} else if (effect === "Sepia") {
|
|
354
|
+
matrix.sepia();
|
|
355
|
+
} else if (effect === "RetroVintage") {
|
|
356
|
+
matrix.negative();
|
|
357
|
+
} else if (effect === "NightVision") {
|
|
358
|
+
matrix.negative();
|
|
359
|
+
} else if (effect === "Normal") {
|
|
360
|
+
matrix.reset();
|
|
361
|
+
}
|
|
362
|
+
}}
|
|
363
|
+
matrix={{
|
|
364
|
+
enabled: true,
|
|
365
|
+
// @ts-ignore
|
|
366
|
+
matrix: CYAN,
|
|
367
|
+
}}
|
|
368
|
+
>
|
|
369
|
+
<PixiAnimatedSprite
|
|
370
|
+
x={x}
|
|
371
|
+
y={y}
|
|
372
|
+
width={width}
|
|
373
|
+
height={height}
|
|
374
|
+
rotation={rotation}
|
|
375
|
+
animationSpeed={1}
|
|
376
|
+
loop={loop}
|
|
377
|
+
isPlaying={!!tlPlay}
|
|
378
|
+
// @ts-ignore
|
|
379
|
+
textures={gifFrameObject}
|
|
380
|
+
onComplete={handleComplete}
|
|
381
|
+
onFrameChange={(currentFrame: number) =>
|
|
382
|
+
setCurrentFrame(currentFrame)
|
|
383
|
+
}
|
|
384
|
+
anchor={0.5}
|
|
385
|
+
{...(!locked &&
|
|
386
|
+
!isDragging && {
|
|
387
|
+
interactive: true,
|
|
388
|
+
buttonMode: true,
|
|
389
|
+
pointerdown: pointerdown,
|
|
390
|
+
pointerover: pointerover,
|
|
391
|
+
pointerout: pointerout,
|
|
392
|
+
pointerup: pointerup,
|
|
393
|
+
mousedown: mousedown,
|
|
394
|
+
mouseup: mouseup,
|
|
395
|
+
mouseover: mouseover,
|
|
396
|
+
mouseout: mouseout,
|
|
397
|
+
})}
|
|
398
|
+
forwardRef={animatedSpriteRef}
|
|
399
|
+
scale={scale}
|
|
400
|
+
/>
|
|
401
|
+
</Filters>
|
|
354
402
|
)}
|
|
355
403
|
</Container>
|
|
356
404
|
</Container>
|
|
@@ -38,6 +38,10 @@ const meta = {
|
|
|
38
38
|
colorCorrection: {
|
|
39
39
|
control: "object",
|
|
40
40
|
description: "colorCorrection of the sprite",
|
|
41
|
+
enabled: {
|
|
42
|
+
control: "boolean",
|
|
43
|
+
description: "enabled of the sprite with color filter mode applied.",
|
|
44
|
+
},
|
|
41
45
|
brightness: {
|
|
42
46
|
control: "number",
|
|
43
47
|
description: "brightness of the sprite",
|
|
@@ -84,9 +88,12 @@ export const Normal: Story = {
|
|
|
84
88
|
args: {
|
|
85
89
|
uniqueId: "surya001", // uniqueId of the sprite
|
|
86
90
|
src: "https://assets.codepen.io/693612/surya.svg",
|
|
91
|
+
applyTransformer: false,
|
|
92
|
+
startAt: 0,
|
|
93
|
+
endAt: 10,
|
|
87
94
|
transformation: {
|
|
88
|
-
x:
|
|
89
|
-
y:
|
|
95
|
+
x: 200,
|
|
96
|
+
y: 200,
|
|
90
97
|
width: 150,
|
|
91
98
|
height: 150,
|
|
92
99
|
anchor: 0.5,
|
|
@@ -95,11 +102,14 @@ export const Normal: Story = {
|
|
|
95
102
|
scale: 1,
|
|
96
103
|
tint: 0xffffff,
|
|
97
104
|
blendMode: 0,
|
|
98
|
-
colorCorrection: {
|
|
105
|
+
colorCorrection: {
|
|
106
|
+
enabled: false,
|
|
107
|
+
contrast: 1,
|
|
108
|
+
saturation: 1,
|
|
109
|
+
exposure: 1,
|
|
110
|
+
blurRadius: 0,
|
|
111
|
+
},
|
|
99
112
|
},
|
|
100
|
-
applyTransformer: false,
|
|
101
|
-
startAt: 0,
|
|
102
|
-
endAt: 10,
|
|
103
113
|
initialAlpha: 1,
|
|
104
114
|
},
|
|
105
115
|
};
|
|
@@ -113,6 +123,9 @@ export const FadeIn: Story = {
|
|
|
113
123
|
args: {
|
|
114
124
|
uniqueId: "surya002", // uniqueId of the sprite
|
|
115
125
|
src: "https://assets.codepen.io/693612/surya.svg",
|
|
126
|
+
applyTransformer: false,
|
|
127
|
+
startAt: 0,
|
|
128
|
+
endAt: 10,
|
|
116
129
|
transformation: {
|
|
117
130
|
x: 100,
|
|
118
131
|
y: 100,
|
|
@@ -127,9 +140,42 @@ export const FadeIn: Story = {
|
|
|
127
140
|
animation: "FADE_IN",
|
|
128
141
|
colorCorrection: {},
|
|
129
142
|
},
|
|
143
|
+
initialAlpha: 0,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
148
|
+
export const Filters: Story = {
|
|
149
|
+
render: (args: any) => (
|
|
150
|
+
<AppStateContextProvider {...args}>
|
|
151
|
+
<PixiImageSprite {...args} />
|
|
152
|
+
</AppStateContextProvider>
|
|
153
|
+
),
|
|
154
|
+
args: {
|
|
155
|
+
uniqueId: "image-filters001", // uniqueId of the sprite
|
|
156
|
+
src: "https://assets.codepen.io/693612/surya.svg",
|
|
130
157
|
applyTransformer: false,
|
|
131
158
|
startAt: 0,
|
|
132
159
|
endAt: 10,
|
|
133
|
-
|
|
160
|
+
transformation: {
|
|
161
|
+
x: 200,
|
|
162
|
+
y: 200,
|
|
163
|
+
width: 150,
|
|
164
|
+
height: 150,
|
|
165
|
+
anchor: 0.5,
|
|
166
|
+
rotation: 0,
|
|
167
|
+
alpha: 1,
|
|
168
|
+
scale: 1,
|
|
169
|
+
tint: 0xffffff,
|
|
170
|
+
blendMode: 0,
|
|
171
|
+
colorCorrection: {
|
|
172
|
+
enabled: true,
|
|
173
|
+
contrast: 1,
|
|
174
|
+
saturation: 2,
|
|
175
|
+
exposure: 1,
|
|
176
|
+
blurRadius: 0,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
initialAlpha: 1,
|
|
134
180
|
},
|
|
135
181
|
};
|
|
@@ -1,114 +1,27 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import { GsapPixieContext } from "../../providers/GsapPixieContextProvider";
|
|
6
|
-
import { Sprite, Container, withFilters } from "@pixi/react";
|
|
7
|
-
import { AdjustmentFilter } from "@pixi/filter-adjustment";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { Sprite, Container } from "@pixi/react";
|
|
8
4
|
import * as PIXI from "pixi.js";
|
|
9
|
-
import gsap from "gsap";
|
|
10
|
-
import PixiTransformer from "../../utils/PixiTransformer";
|
|
11
|
-
|
|
12
5
|
// @ts-ignore
|
|
13
6
|
import isEmpty from "lodash/isEmpty";
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
type PixiImageSpriteProps = {
|
|
18
|
-
uniqueId: string;
|
|
19
|
-
src: string;
|
|
20
|
-
startAt: number;
|
|
21
|
-
endAt: number;
|
|
22
|
-
initialAlpha: number;
|
|
23
|
-
transformation: {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
width: number;
|
|
27
|
-
height: number;
|
|
28
|
-
anchor: number;
|
|
29
|
-
rotation?: number;
|
|
30
|
-
alpha?: number;
|
|
31
|
-
scale?: number | [number, number];
|
|
32
|
-
tint?: number;
|
|
33
|
-
blendMode?: number;
|
|
34
|
-
animation?: string;
|
|
35
|
-
colorCorrection?: {
|
|
36
|
-
enabled?: boolean;
|
|
37
|
-
temperature?: number;
|
|
38
|
-
hue?: number;
|
|
39
|
-
contrast?: number;
|
|
40
|
-
saturation?: number;
|
|
41
|
-
exposure?: number;
|
|
42
|
-
reset?: boolean;
|
|
43
|
-
sharpness?: number;
|
|
44
|
-
value?: number;
|
|
45
|
-
levels?: number;
|
|
46
|
-
luminance?: number;
|
|
47
|
-
enhance?: number;
|
|
48
|
-
blurRadius?: number;
|
|
49
|
-
red?: number;
|
|
50
|
-
green?: number;
|
|
51
|
-
blue?: number;
|
|
52
|
-
alpha?: number;
|
|
53
|
-
scaleInput?: number;
|
|
54
|
-
};
|
|
55
|
-
effect?: string;
|
|
56
|
-
};
|
|
57
|
-
pointerdown?: () => void;
|
|
58
|
-
pointerup?: () => void;
|
|
59
|
-
mousedown?: () => void;
|
|
60
|
-
mouseup?: () => void;
|
|
61
|
-
pointerover?: () => void;
|
|
62
|
-
mouseover?: () => void;
|
|
63
|
-
mouseout?: () => void;
|
|
64
|
-
applyTransformer?: boolean;
|
|
65
|
-
onAnchorTransformationEnd?: (endData: any) => void;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const Filters = withFilters(Container, {
|
|
69
|
-
blur: PIXI.filters.BlurFilter,
|
|
70
|
-
adjust: AdjustmentFilter,
|
|
71
|
-
matrix: PIXI.filters.ColorMatrixFilter,
|
|
72
|
-
});
|
|
7
|
+
// setup hocs
|
|
8
|
+
import AbstractContainer from "../../hocs/AbstractContainer";
|
|
9
|
+
import { PixiBaseSpriteProps } from "../../types/BaseProps";
|
|
73
10
|
|
|
74
|
-
|
|
75
|
-
const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
76
|
-
|
|
77
|
-
const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
|
|
11
|
+
const PixiImageSprite: React.FC<PixiBaseSpriteProps> = (props) => {
|
|
78
12
|
//// State
|
|
79
|
-
const [isMounted, setIsMounted] = React.useState(false);
|
|
80
|
-
const [, setIsTransformerDragging] = useState(false);
|
|
81
|
-
const [, setIsMouseOverTransformer] = useState(false);
|
|
82
13
|
|
|
83
|
-
console.log("allProps", props);
|
|
84
14
|
//// Refs
|
|
85
15
|
const imageRef = useRef<PIXI.Sprite>(null);
|
|
86
|
-
const containerRef = useRef<PIXI.Container>(null);
|
|
87
|
-
const parentNode = useRef<PIXI.Container>(null);
|
|
88
16
|
const imgGroupRef = useRef<PIXI.Container>(null);
|
|
89
|
-
const transformerRef = useRef<PIXI.Container>(null);
|
|
90
17
|
|
|
91
18
|
//// Context
|
|
92
|
-
const { tl } = useContext(GsapPixieContext);
|
|
93
19
|
|
|
94
20
|
/// 1001
|
|
95
21
|
// console.log("contxt Values", tl);
|
|
96
22
|
const {
|
|
97
|
-
uniqueId,
|
|
98
23
|
src,
|
|
99
|
-
|
|
100
|
-
endAt,
|
|
101
|
-
initialAlpha,
|
|
102
|
-
transformation: {
|
|
103
|
-
x,
|
|
104
|
-
y,
|
|
105
|
-
width,
|
|
106
|
-
height,
|
|
107
|
-
anchor,
|
|
108
|
-
animation,
|
|
109
|
-
colorCorrection,
|
|
110
|
-
effect,
|
|
111
|
-
},
|
|
24
|
+
transformation: { x, y, width, height, anchor },
|
|
112
25
|
pointerdown,
|
|
113
26
|
pointerup,
|
|
114
27
|
mousedown,
|
|
@@ -116,193 +29,31 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
|
|
|
116
29
|
pointerover,
|
|
117
30
|
mouseover,
|
|
118
31
|
mouseout,
|
|
119
|
-
applyTransformer,
|
|
120
|
-
onAnchorTransformationEnd,
|
|
121
32
|
} = props;
|
|
122
33
|
|
|
123
|
-
// color corrections
|
|
124
|
-
const {
|
|
125
|
-
contrast = 1,
|
|
126
|
-
saturation = 1,
|
|
127
|
-
exposure = 1,
|
|
128
|
-
blurRadius = 0,
|
|
129
|
-
alpha = 1,
|
|
130
|
-
} = colorCorrection || {};
|
|
131
|
-
|
|
132
|
-
/** adjustment filter */
|
|
133
|
-
const adjustments = {
|
|
134
|
-
brightness: exposure,
|
|
135
|
-
contrast,
|
|
136
|
-
saturation,
|
|
137
|
-
alpha,
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/** handle on tranformer onchange */
|
|
141
|
-
const handleOnTransformChange = React.useCallback(() => {
|
|
142
|
-
setIsTransformerDragging(true);
|
|
143
|
-
}, []);
|
|
144
|
-
|
|
145
|
-
// transformer to handle sprite transformation
|
|
146
|
-
const handleOnTransformEnd = React.useCallback(
|
|
147
|
-
(endData: TransformationEnd) => {
|
|
148
|
-
console.log("changeEnd", endData);
|
|
149
|
-
if (onAnchorTransformationEnd) {
|
|
150
|
-
console.log("running onAnchorTransformationEnd");
|
|
151
|
-
onAnchorTransformationEnd(endData);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
[]
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
useEffect(() => {
|
|
158
|
-
let ctx = gsap.context(() => {});
|
|
159
|
-
if (containerRef.current && tl.current) {
|
|
160
|
-
const data = {
|
|
161
|
-
duration: Number(endAt) - Number(startAt),
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const ease = getAnimByName(animation || "None");
|
|
165
|
-
ctx = gsap.context(() => {
|
|
166
|
-
if (!isEmpty(ease.from)) {
|
|
167
|
-
tl.current
|
|
168
|
-
.from(containerRef.current, { ...ease.from }, startAt)
|
|
169
|
-
.to(imgGroupRef.current, { alpha: 1, duration: 0.2 }, startAt)
|
|
170
|
-
.from(imgGroupRef.current, { ...data }, startAt)
|
|
171
|
-
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
172
|
-
} else if (!isEmpty(ease.to)) {
|
|
173
|
-
tl.current
|
|
174
|
-
.to(
|
|
175
|
-
containerRef.current,
|
|
176
|
-
{ alpha: 1, duration: 0.2, ...ease.to },
|
|
177
|
-
startAt
|
|
178
|
-
)
|
|
179
|
-
.from(imgGroupRef.current, { ...data }, startAt)
|
|
180
|
-
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
181
|
-
} else if (!isEmpty(ease.fromTo)) {
|
|
182
|
-
tl.current
|
|
183
|
-
.fromTo(
|
|
184
|
-
containerRef.current,
|
|
185
|
-
ease.fromTo?.from,
|
|
186
|
-
ease.fromTo?.to,
|
|
187
|
-
startAt
|
|
188
|
-
)
|
|
189
|
-
.from(imgGroupRef.current, { ...data }, startAt)
|
|
190
|
-
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
191
|
-
} else {
|
|
192
|
-
tl.current
|
|
193
|
-
.to(containerRef.current, { alpha: 1, duration: 0.01 }, startAt)
|
|
194
|
-
.from(imgGroupRef.current, { ...data }, startAt)
|
|
195
|
-
.to(
|
|
196
|
-
containerRef.current,
|
|
197
|
-
{ alpha: 0, duration: 0.1 },
|
|
198
|
-
Number(endAt) - Number(0.1)
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
return () => ctx.revert(); // cleanup!
|
|
204
|
-
}, [animation, startAt, endAt]);
|
|
205
|
-
|
|
206
|
-
React.useEffect(() => {
|
|
207
|
-
if (containerRef.current) {
|
|
208
|
-
setIsMounted(true);
|
|
209
|
-
}
|
|
210
|
-
}, []);
|
|
211
|
-
|
|
212
34
|
return (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
>
|
|
224
|
-
{colorCorrection && colorCorrection.enabled ? (
|
|
225
|
-
<Filters
|
|
226
|
-
scale={1}
|
|
227
|
-
blur={{ blur: blurRadius, quality: 4 }}
|
|
228
|
-
adjust={adjustments}
|
|
229
|
-
apply={({ matrix }: { matrix: any }) => {
|
|
230
|
-
if (effect === "BlackAndWhite") {
|
|
231
|
-
matrix.desaturate();
|
|
232
|
-
} else if (effect === "Sepia") {
|
|
233
|
-
matrix.sepia();
|
|
234
|
-
} else if (effect === "RetroVintage") {
|
|
235
|
-
matrix.negative();
|
|
236
|
-
} else if (effect === "NightVision") {
|
|
237
|
-
matrix.negative();
|
|
238
|
-
} else if (effect === "Normal") {
|
|
239
|
-
matrix.reset();
|
|
240
|
-
}
|
|
241
|
-
}}
|
|
242
|
-
matrix={{
|
|
243
|
-
enabled: true,
|
|
244
|
-
// @ts-ignore
|
|
245
|
-
matrix: CYAN,
|
|
246
|
-
}}
|
|
247
|
-
>
|
|
248
|
-
{/* @ts-ignore */}
|
|
249
|
-
<Container ref={imgGroupRef}>
|
|
250
|
-
<Sprite
|
|
251
|
-
image={src}
|
|
252
|
-
width={width}
|
|
253
|
-
height={height}
|
|
254
|
-
anchor={anchor}
|
|
255
|
-
ref={imageRef}
|
|
256
|
-
x={x}
|
|
257
|
-
y={y}
|
|
258
|
-
// @ts-ignore
|
|
259
|
-
interactive={true}
|
|
260
|
-
pointerdown={pointerdown}
|
|
261
|
-
pointerup={pointerup}
|
|
262
|
-
pointerover={pointerover}
|
|
263
|
-
mousedown={mousedown}
|
|
264
|
-
mouseup={mouseup}
|
|
265
|
-
mouseover={mouseover}
|
|
266
|
-
mouseout={mouseout}
|
|
267
|
-
/>
|
|
268
|
-
</Container>
|
|
269
|
-
</Filters>
|
|
270
|
-
) : (
|
|
35
|
+
<AbstractContainer {...props}>
|
|
36
|
+
<Container ref={imgGroupRef}>
|
|
37
|
+
<Sprite
|
|
38
|
+
image={src}
|
|
39
|
+
width={width}
|
|
40
|
+
height={height}
|
|
41
|
+
anchor={anchor}
|
|
42
|
+
ref={imageRef}
|
|
43
|
+
x={x}
|
|
44
|
+
y={y}
|
|
271
45
|
// @ts-ignore
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
y={y}
|
|
281
|
-
// @ts-ignore
|
|
282
|
-
interactive={true}
|
|
283
|
-
pointerdown={pointerdown}
|
|
284
|
-
pointerup={pointerup}
|
|
285
|
-
pointerover={pointerover}
|
|
286
|
-
mousedown={mousedown}
|
|
287
|
-
mouseup={mouseup}
|
|
288
|
-
mouseover={mouseover}
|
|
289
|
-
mouseout={mouseout}
|
|
290
|
-
/>
|
|
291
|
-
</Container>
|
|
292
|
-
)}
|
|
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}
|
|
46
|
+
interactive={true}
|
|
47
|
+
pointerdown={pointerdown}
|
|
48
|
+
pointerup={pointerup}
|
|
49
|
+
pointerover={pointerover}
|
|
50
|
+
mousedown={mousedown}
|
|
51
|
+
mouseup={mouseup}
|
|
52
|
+
mouseover={mouseover}
|
|
53
|
+
mouseout={mouseout}
|
|
303
54
|
/>
|
|
304
|
-
|
|
305
|
-
</
|
|
55
|
+
</Container>
|
|
56
|
+
</AbstractContainer>
|
|
306
57
|
);
|
|
307
58
|
};
|
|
308
59
|
|