reacthub-pixitweenjs 0.2.4 → 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.
- package/CHANGELOG.md +14 -0
- package/build-storybook.log +79 -476
- package/package.json +26 -29
- package/src/components/PixiAnimatedSprite/PixiAnimatedSprite.tsx +51 -0
- package/src/components/PixiAnimatedSprite/index.ts +2 -0
- package/src/components/PixiAudioSprite/PixiAudioSprite.stories.tsx +61 -0
- package/src/components/PixiAudioSprite/PixiAudioSprite.tsx +212 -0
- package/src/components/PixiAudioSprite/index.ts +1 -0
- package/src/components/PixiGifSprite/PixiGifSprite.stories.tsx +135 -0
- package/src/components/PixiGifSprite/PixiGifSprite.tsx +451 -0
- package/src/components/PixiGifSprite/index.ts +2 -0
- package/src/components/PixiImageSprite/PixiImageSprite.stories.tsx +11 -0
- package/src/components/PixiImageSprite/PixiImageSprite.tsx +30 -36
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +137 -0
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +378 -0
- package/src/components/PixiSVGSprite/index.ts +1 -0
- package/src/components/PixiVideoSprite/PixiVideoSprite.stories.tsx +147 -0
- package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +684 -0
- package/src/components/PixiVideoSprite/PixiVideoSpriteBackup.txt +755 -0
- package/src/components/PixiVideoSprite/index.ts +1 -0
- package/src/declare.module.ts +5 -0
- package/src/providers/GsapPixieContextProvider.tsx +94 -8
- package/src/reacthub-react-bindings.d.ts +27 -0
- package/src/utils/AppStateProvider.tsx +15 -26
- package/src/utils/AppStateStage.tsx +1 -1
- package/src/utils/PixiStage.tsx +1 -5
- package/src/utils/PixiTransformer.tsx +100 -0
- package/src/utils/VideoSeekBar.tsx +34 -23
- package/src/utils/useDebounce.tsx +15 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { PixiSvgPathSprite } from ".";
|
|
3
|
+
import { AppStateContextProvider } from "../../utils/AppStateProvider";
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Components/SvgSprite",
|
|
8
|
+
component: PixiSvgPathSprite,
|
|
9
|
+
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
argTypes: {
|
|
12
|
+
uniqueId: {
|
|
13
|
+
control: "text",
|
|
14
|
+
description: "uniqueId of the sprite",
|
|
15
|
+
},
|
|
16
|
+
src: {
|
|
17
|
+
control: "text",
|
|
18
|
+
description: "source of the image",
|
|
19
|
+
},
|
|
20
|
+
transformation: {
|
|
21
|
+
control: "object",
|
|
22
|
+
description: "transformation of the sprite",
|
|
23
|
+
x: { control: "number", description: "x position of the sprite" },
|
|
24
|
+
y: { control: "number", description: "y position of the sprite" },
|
|
25
|
+
width: { control: "number", description: "width of the sprite" },
|
|
26
|
+
height: { control: "number", description: "height of the sprite" },
|
|
27
|
+
anchor: { control: "number", description: "anchor of the sprite" },
|
|
28
|
+
rotation: { control: "number", description: "rotation of the sprite" },
|
|
29
|
+
alpha: {
|
|
30
|
+
control: "number",
|
|
31
|
+
min: 0,
|
|
32
|
+
max: 1,
|
|
33
|
+
description: "alpha of the sprite",
|
|
34
|
+
},
|
|
35
|
+
scale: { control: "number", description: "scale of the sprite" },
|
|
36
|
+
tint: { control: "number", description: "tint of the sprite" },
|
|
37
|
+
blendMode: { control: "number", description: "blendMode of the sprite" },
|
|
38
|
+
colorCorrection: {
|
|
39
|
+
control: "object",
|
|
40
|
+
description: "colorCorrection of the sprite",
|
|
41
|
+
brightness: {
|
|
42
|
+
control: "number",
|
|
43
|
+
description: "brightness of the sprite",
|
|
44
|
+
},
|
|
45
|
+
contrast: { control: "number", description: "contrast of the sprite" },
|
|
46
|
+
saturation: {
|
|
47
|
+
control: "number",
|
|
48
|
+
description: "saturation of the sprite",
|
|
49
|
+
},
|
|
50
|
+
alpha: { control: "number", description: "alpha of the sprite" },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
applyTransformer: { control: "boolean", description: "applyTransformer" },
|
|
54
|
+
startAt: { control: "number", description: "startAt" },
|
|
55
|
+
endAt: { control: "number", description: "endAt" },
|
|
56
|
+
initialAlpha: {
|
|
57
|
+
control: "number",
|
|
58
|
+
min: 0,
|
|
59
|
+
max: 1,
|
|
60
|
+
description: "sprite initial alpha value (default 1)",
|
|
61
|
+
},
|
|
62
|
+
onAnchorTransformationEnd: {
|
|
63
|
+
action: "onAnchorTransformationEnd",
|
|
64
|
+
description:
|
|
65
|
+
"on transforamtion end the event is fire callback with latest sprite transformation properties.",
|
|
66
|
+
},
|
|
67
|
+
pointerdown: {
|
|
68
|
+
action: "pointerdown",
|
|
69
|
+
description: "pointerdown event",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
} satisfies Meta<typeof PixiSvgPathSprite>;
|
|
73
|
+
|
|
74
|
+
export default meta;
|
|
75
|
+
type Story = StoryObj<typeof meta>;
|
|
76
|
+
|
|
77
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
78
|
+
export const Normal: Story = {
|
|
79
|
+
render: (args: any) => (
|
|
80
|
+
<AppStateContextProvider {...args}>
|
|
81
|
+
<PixiSvgPathSprite {...args} />
|
|
82
|
+
</AppStateContextProvider>
|
|
83
|
+
),
|
|
84
|
+
args: {
|
|
85
|
+
uniqueId: "svg001", // uniqueId of the sprite
|
|
86
|
+
path: "M 100 100 L 300 100 L 200 300 z",
|
|
87
|
+
transformation: {
|
|
88
|
+
x: 100,
|
|
89
|
+
y: 100,
|
|
90
|
+
width: 150,
|
|
91
|
+
height: 150,
|
|
92
|
+
anchor: 0.5,
|
|
93
|
+
rotation: 0,
|
|
94
|
+
alpha: 1,
|
|
95
|
+
scale: 1,
|
|
96
|
+
tint: 0xffffff,
|
|
97
|
+
blendMode: 0,
|
|
98
|
+
colorCorrection: {},
|
|
99
|
+
fill: "#FFC0CB",
|
|
100
|
+
},
|
|
101
|
+
applyTransformer: false,
|
|
102
|
+
startAt: 0,
|
|
103
|
+
endAt: 10,
|
|
104
|
+
initialAlpha: 1,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const FadeIn: Story = {
|
|
109
|
+
render: (args: any) => (
|
|
110
|
+
<AppStateContextProvider {...args}>
|
|
111
|
+
<PixiSvgPathSprite {...args} />
|
|
112
|
+
</AppStateContextProvider>
|
|
113
|
+
),
|
|
114
|
+
args: {
|
|
115
|
+
uniqueId: "surya002", // uniqueId of the sprite
|
|
116
|
+
path: "M 100, 100 m -75, 0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0",
|
|
117
|
+
transformation: {
|
|
118
|
+
x: 100,
|
|
119
|
+
y: 100,
|
|
120
|
+
width: 150,
|
|
121
|
+
height: 150,
|
|
122
|
+
anchor: 0.5,
|
|
123
|
+
rotation: 0,
|
|
124
|
+
alpha: 1,
|
|
125
|
+
scale: 1,
|
|
126
|
+
tint: 0xffffff,
|
|
127
|
+
blendMode: 0,
|
|
128
|
+
animation: "FADE_IN",
|
|
129
|
+
colorCorrection: {},
|
|
130
|
+
fill: "#fe2c54",
|
|
131
|
+
},
|
|
132
|
+
applyTransformer: false,
|
|
133
|
+
startAt: 0,
|
|
134
|
+
endAt: 10,
|
|
135
|
+
initialAlpha: 0,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
@@ -0,0 +1,378 @@
|
|
|
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 { GsapPixieContext } from "../../providers/GsapPixieContextProvider";
|
|
6
|
+
import { Sprite, Container, useApp, withFilters } from "@pixi/react";
|
|
7
|
+
import { AdjustmentFilter } from "@pixi/filter-adjustment";
|
|
8
|
+
import * as PIXI from "pixi.js";
|
|
9
|
+
import gsap from "gsap";
|
|
10
|
+
import { SVG } from "pixi-svg";
|
|
11
|
+
import PixiTransformer from "../../utils/PixiTransformer";
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
import svgpath from "svgpath";
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
import isEmpty from "lodash/isEmpty";
|
|
16
|
+
import { getAnimByName } from "../../utils/GsapAnim";
|
|
17
|
+
import { TransformationEnd } from "../../types/transformation";
|
|
18
|
+
|
|
19
|
+
type PixiSvgPathSpriteProps = {
|
|
20
|
+
uniqueId: string;
|
|
21
|
+
path: string;
|
|
22
|
+
startAt: number;
|
|
23
|
+
endAt: number;
|
|
24
|
+
initialAlpha: number;
|
|
25
|
+
transformation: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
anchor: number;
|
|
31
|
+
rotation?: number;
|
|
32
|
+
alpha?: number;
|
|
33
|
+
scale?: number | [number, number];
|
|
34
|
+
tint?: number;
|
|
35
|
+
blendMode?: number;
|
|
36
|
+
animation?: string;
|
|
37
|
+
fill?: string;
|
|
38
|
+
fontWeight?: string;
|
|
39
|
+
fontStyle?: string;
|
|
40
|
+
stroke?: string;
|
|
41
|
+
strokeWidth?: number;
|
|
42
|
+
blurRadius?: number;
|
|
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
|
+
const Filters = withFilters(Container, {
|
|
80
|
+
blur: PIXI.filters.BlurFilter,
|
|
81
|
+
adjust: AdjustmentFilter,
|
|
82
|
+
matrix: PIXI.filters.ColorMatrixFilter,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/** filter config */
|
|
86
|
+
const config = {
|
|
87
|
+
dot: {
|
|
88
|
+
scale: 1,
|
|
89
|
+
angle: 5,
|
|
90
|
+
},
|
|
91
|
+
blur: {
|
|
92
|
+
blur: 0,
|
|
93
|
+
quality: 4,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** CYAN Filters */
|
|
98
|
+
const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
99
|
+
|
|
100
|
+
const PixiSvgPathSprite: React.FC<PixiSvgPathSpriteProps> = (props) => {
|
|
101
|
+
//// State
|
|
102
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
103
|
+
const [isTransformerDragging, setIsTransformerDragging] = useState(false);
|
|
104
|
+
const [isMouseOverTransformer, setIsMouseOverTransformer] = useState(false);
|
|
105
|
+
const [texture, setTexture] = React.useState<any>(null);
|
|
106
|
+
|
|
107
|
+
console.log("allProps", props);
|
|
108
|
+
//// Refs
|
|
109
|
+
const imageRef = useRef<PIXI.Sprite>(null);
|
|
110
|
+
const containerRef = useRef<PIXI.Container>(null);
|
|
111
|
+
const parentNode = useRef<PIXI.Container>(null);
|
|
112
|
+
const imgGroupRef = useRef<PIXI.Container>(null);
|
|
113
|
+
const transformerRef = useRef<PIXI.Container>(null);
|
|
114
|
+
|
|
115
|
+
//// Context
|
|
116
|
+
const { tl } = useContext(GsapPixieContext);
|
|
117
|
+
|
|
118
|
+
/// 1001
|
|
119
|
+
// console.log("contxt Values", tl);
|
|
120
|
+
const {
|
|
121
|
+
uniqueId,
|
|
122
|
+
path,
|
|
123
|
+
startAt,
|
|
124
|
+
endAt,
|
|
125
|
+
initialAlpha,
|
|
126
|
+
transformation: {
|
|
127
|
+
x,
|
|
128
|
+
y,
|
|
129
|
+
width,
|
|
130
|
+
height,
|
|
131
|
+
anchor,
|
|
132
|
+
animation,
|
|
133
|
+
colorCorrection,
|
|
134
|
+
effect,
|
|
135
|
+
fill,
|
|
136
|
+
fontWeight,
|
|
137
|
+
fontStyle,
|
|
138
|
+
stroke = "none",
|
|
139
|
+
strokeWidth = 0,
|
|
140
|
+
blurRadius = 0,
|
|
141
|
+
},
|
|
142
|
+
pointerdown,
|
|
143
|
+
pointerup,
|
|
144
|
+
mousedown,
|
|
145
|
+
mouseup,
|
|
146
|
+
pointerover,
|
|
147
|
+
mouseover,
|
|
148
|
+
mouseout,
|
|
149
|
+
applyTransformer,
|
|
150
|
+
onAnchorTransformationEnd,
|
|
151
|
+
...restProps
|
|
152
|
+
} = props;
|
|
153
|
+
|
|
154
|
+
// color corrections
|
|
155
|
+
const {
|
|
156
|
+
enabled = false,
|
|
157
|
+
temperature = 1,
|
|
158
|
+
hue = 1,
|
|
159
|
+
contrast = 1,
|
|
160
|
+
saturation = 1,
|
|
161
|
+
exposure = 1,
|
|
162
|
+
reset,
|
|
163
|
+
sharpness = 1,
|
|
164
|
+
value = 0,
|
|
165
|
+
levels = 1,
|
|
166
|
+
luminance = 0,
|
|
167
|
+
enhance = 0,
|
|
168
|
+
red = 150,
|
|
169
|
+
green = 150,
|
|
170
|
+
blue = 150,
|
|
171
|
+
alpha = 1,
|
|
172
|
+
scaleInput = 1,
|
|
173
|
+
} = colorCorrection || {};
|
|
174
|
+
|
|
175
|
+
const app = useApp();
|
|
176
|
+
|
|
177
|
+
/** adjustment filter */
|
|
178
|
+
const adjustments = {
|
|
179
|
+
brightness: exposure,
|
|
180
|
+
contrast,
|
|
181
|
+
saturation,
|
|
182
|
+
alpha,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const fillColor = PIXI.utils.string2hex(fill || "#262730");
|
|
186
|
+
|
|
187
|
+
/** handle on tranformer onchange */
|
|
188
|
+
const handleOnTransformChange = React.useCallback(() => {
|
|
189
|
+
setIsTransformerDragging(true);
|
|
190
|
+
}, []);
|
|
191
|
+
|
|
192
|
+
// transformer to handle sprite transformation
|
|
193
|
+
const handleOnTransformEnd = React.useCallback(
|
|
194
|
+
(endData: TransformationEnd) => {
|
|
195
|
+
console.log("changeEnd", endData);
|
|
196
|
+
if (onAnchorTransformationEnd) {
|
|
197
|
+
console.log("running onAnchorTransformationEnd");
|
|
198
|
+
onAnchorTransformationEnd(endData);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
[]
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
let ctx = gsap.context(() => {});
|
|
206
|
+
if (containerRef.current && tl.current) {
|
|
207
|
+
const data = {
|
|
208
|
+
duration: Number(endAt) - Number(startAt),
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const ease = getAnimByName(animation || "None");
|
|
212
|
+
ctx = gsap.context(() => {
|
|
213
|
+
if (!isEmpty(ease.from)) {
|
|
214
|
+
tl.current
|
|
215
|
+
.from(containerRef.current, { ...ease.from }, startAt)
|
|
216
|
+
.to(imgGroupRef.current, { alpha: 1, duration: 0.2 }, startAt)
|
|
217
|
+
.from(imgGroupRef.current, { ...data }, startAt)
|
|
218
|
+
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
219
|
+
} else if (!isEmpty(ease.to)) {
|
|
220
|
+
tl.current
|
|
221
|
+
.to(
|
|
222
|
+
containerRef.current,
|
|
223
|
+
{ alpha: 1, duration: 0.2, ...ease.to },
|
|
224
|
+
startAt
|
|
225
|
+
)
|
|
226
|
+
.from(imgGroupRef.current, { ...data }, startAt)
|
|
227
|
+
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
228
|
+
} else if (!isEmpty(ease.fromTo)) {
|
|
229
|
+
tl.current
|
|
230
|
+
.fromTo(
|
|
231
|
+
containerRef.current,
|
|
232
|
+
ease.fromTo?.from,
|
|
233
|
+
ease.fromTo?.to,
|
|
234
|
+
startAt
|
|
235
|
+
)
|
|
236
|
+
.from(imgGroupRef.current, { ...data }, startAt)
|
|
237
|
+
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
238
|
+
} else {
|
|
239
|
+
tl.current
|
|
240
|
+
.to(containerRef.current, { alpha: 1, duration: 0.01 }, startAt)
|
|
241
|
+
.from(imgGroupRef.current, { ...data }, startAt)
|
|
242
|
+
.to(
|
|
243
|
+
containerRef.current,
|
|
244
|
+
{ alpha: 0, duration: 0.1 },
|
|
245
|
+
Number(endAt) - Number(0.1)
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return () => ctx.revert(); // cleanup!
|
|
251
|
+
}, [animation, startAt, endAt]);
|
|
252
|
+
|
|
253
|
+
React.useEffect(() => {
|
|
254
|
+
if (containerRef.current) {
|
|
255
|
+
setIsMounted(true);
|
|
256
|
+
}
|
|
257
|
+
}, []);
|
|
258
|
+
|
|
259
|
+
React.useEffect(() => {
|
|
260
|
+
const transformedPath = svgpath(path).scale(5).translate(0, 0).toString();
|
|
261
|
+
// console.log('path', path);
|
|
262
|
+
// console.log('transformedPath', transformedPath);
|
|
263
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}">
|
|
264
|
+
<path stroke="${stroke}" stroke-width="${strokeWidth}" fill="${fill}" d="${transformedPath}">
|
|
265
|
+
</path>
|
|
266
|
+
</svg>`;
|
|
267
|
+
|
|
268
|
+
const svgObject = new SVG(svg);
|
|
269
|
+
const tex = app.renderer.generateTexture(svgObject);
|
|
270
|
+
setTexture(tex);
|
|
271
|
+
return () => {
|
|
272
|
+
// removeTransformer();
|
|
273
|
+
};
|
|
274
|
+
}, [app, path, stroke, strokeWidth, fill]);
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
// @ts-ignore
|
|
278
|
+
<Container ref={parentNode}>
|
|
279
|
+
{/* @ts-ignore */}
|
|
280
|
+
<Container
|
|
281
|
+
ref={containerRef}
|
|
282
|
+
alpha={initialAlpha}
|
|
283
|
+
position={[x, y]}
|
|
284
|
+
pivot={[x, y]}
|
|
285
|
+
width={width}
|
|
286
|
+
height={height}
|
|
287
|
+
>
|
|
288
|
+
{colorCorrection && colorCorrection.enabled ? (
|
|
289
|
+
<Filters
|
|
290
|
+
scale={1}
|
|
291
|
+
blur={{ blur: blurRadius, quality: 4 }}
|
|
292
|
+
adjust={adjustments}
|
|
293
|
+
apply={({ matrix }: { matrix: any }) => {
|
|
294
|
+
if (effect === "BlackAndWhite") {
|
|
295
|
+
matrix.desaturate();
|
|
296
|
+
} else if (effect === "Sepia") {
|
|
297
|
+
matrix.sepia();
|
|
298
|
+
} else if (effect === "RetroVintage") {
|
|
299
|
+
matrix.negative();
|
|
300
|
+
} else if (effect === "NightVision") {
|
|
301
|
+
matrix.negative();
|
|
302
|
+
} else if (effect === "Normal") {
|
|
303
|
+
matrix.reset();
|
|
304
|
+
}
|
|
305
|
+
}}
|
|
306
|
+
matrix={{
|
|
307
|
+
enabled: true,
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
matrix: CYAN,
|
|
310
|
+
}}
|
|
311
|
+
>
|
|
312
|
+
{/* @ts-ignore */}
|
|
313
|
+
|
|
314
|
+
<Container ref={imgGroupRef}>
|
|
315
|
+
{texture && (
|
|
316
|
+
<Sprite
|
|
317
|
+
texture={texture}
|
|
318
|
+
width={width}
|
|
319
|
+
height={height}
|
|
320
|
+
anchor={anchor}
|
|
321
|
+
ref={imageRef}
|
|
322
|
+
x={x}
|
|
323
|
+
y={y}
|
|
324
|
+
// @ts-ignore
|
|
325
|
+
interactive={true}
|
|
326
|
+
pointerdown={pointerdown}
|
|
327
|
+
pointerup={pointerup}
|
|
328
|
+
pointerover={pointerover}
|
|
329
|
+
mousedown={mousedown}
|
|
330
|
+
mouseup={mouseup}
|
|
331
|
+
mouseover={mouseover}
|
|
332
|
+
mouseout={mouseout}
|
|
333
|
+
/>
|
|
334
|
+
)}
|
|
335
|
+
</Container>
|
|
336
|
+
</Filters>
|
|
337
|
+
) : (
|
|
338
|
+
// @ts-ignore
|
|
339
|
+
<Container ref={imgGroupRef}>
|
|
340
|
+
{texture && (
|
|
341
|
+
<Sprite
|
|
342
|
+
texture={texture}
|
|
343
|
+
width={width}
|
|
344
|
+
height={height}
|
|
345
|
+
anchor={anchor}
|
|
346
|
+
ref={imageRef}
|
|
347
|
+
x={x}
|
|
348
|
+
y={y}
|
|
349
|
+
// @ts-ignore
|
|
350
|
+
interactive={true}
|
|
351
|
+
pointerdown={pointerdown}
|
|
352
|
+
pointerup={pointerup}
|
|
353
|
+
pointerover={pointerover}
|
|
354
|
+
mousedown={mousedown}
|
|
355
|
+
mouseup={mouseup}
|
|
356
|
+
mouseover={mouseover}
|
|
357
|
+
mouseout={mouseout}
|
|
358
|
+
/>
|
|
359
|
+
)}
|
|
360
|
+
</Container>
|
|
361
|
+
)}
|
|
362
|
+
</Container>
|
|
363
|
+
{applyTransformer && (
|
|
364
|
+
<PixiTransformer
|
|
365
|
+
pixiTransformerRef={transformerRef}
|
|
366
|
+
imageRef={containerRef}
|
|
367
|
+
isMounted={isMounted}
|
|
368
|
+
transformCommit={handleOnTransformEnd}
|
|
369
|
+
transformChange={handleOnTransformChange}
|
|
370
|
+
mouseoverEvent={setIsMouseOverTransformer}
|
|
371
|
+
uniqueId={uniqueId}
|
|
372
|
+
/>
|
|
373
|
+
)}
|
|
374
|
+
</Container>
|
|
375
|
+
);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
export default PixiSvgPathSprite;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PixiSvgPathSprite } from "./PixiSvgPathSprite";
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { PixiVideoSprite } from ".";
|
|
3
|
+
import { AppStateContextProvider } from "../../utils/AppStateProvider";
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Components/VideoSprite",
|
|
8
|
+
component: PixiVideoSprite,
|
|
9
|
+
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
argTypes: {
|
|
12
|
+
uniqueId: {
|
|
13
|
+
control: "text",
|
|
14
|
+
description: "uniqueId of the sprite",
|
|
15
|
+
},
|
|
16
|
+
src: {
|
|
17
|
+
control: "text",
|
|
18
|
+
description: "source of the image",
|
|
19
|
+
},
|
|
20
|
+
transformation: {
|
|
21
|
+
control: "object",
|
|
22
|
+
description: "transformation of the sprite",
|
|
23
|
+
x: { control: "number", description: "x position of the sprite" },
|
|
24
|
+
y: { control: "number", description: "y position of the sprite" },
|
|
25
|
+
width: { control: "number", description: "width of the sprite" },
|
|
26
|
+
height: { control: "number", description: "height of the sprite" },
|
|
27
|
+
anchor: { control: "number", description: "anchor of the sprite" },
|
|
28
|
+
rotation: { control: "number", description: "rotation of the sprite" },
|
|
29
|
+
alpha: {
|
|
30
|
+
control: "number",
|
|
31
|
+
min: 0,
|
|
32
|
+
max: 1,
|
|
33
|
+
description: "alpha of the sprite",
|
|
34
|
+
},
|
|
35
|
+
scale: { control: "number", description: "scale of the sprite" },
|
|
36
|
+
tint: { control: "number", description: "tint of the sprite" },
|
|
37
|
+
blendMode: { control: "number", description: "blendMode of the sprite" },
|
|
38
|
+
colorCorrection: {
|
|
39
|
+
control: "object",
|
|
40
|
+
description: "colorCorrection of the sprite",
|
|
41
|
+
brightness: {
|
|
42
|
+
control: "number",
|
|
43
|
+
description: "brightness of the sprite",
|
|
44
|
+
},
|
|
45
|
+
contrast: { control: "number", description: "contrast of the sprite" },
|
|
46
|
+
saturation: {
|
|
47
|
+
control: "number",
|
|
48
|
+
description: "saturation of the sprite",
|
|
49
|
+
},
|
|
50
|
+
alpha: { control: "number", description: "alpha of the sprite" },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
applyTransformer: { control: "boolean", description: "applyTransformer" },
|
|
54
|
+
startAt: { control: "number", description: "startAt" },
|
|
55
|
+
endAt: { control: "number", description: "endAt" },
|
|
56
|
+
frameStartAt: { control: "number", description: "frameStartAt" },
|
|
57
|
+
frameEndAt: { control: "number", description: "frameEndAt" },
|
|
58
|
+
mute: { control: "boolean", description: "mute" },
|
|
59
|
+
locked: { control: "boolean", description: "locked" },
|
|
60
|
+
initialAlpha: {
|
|
61
|
+
control: "number",
|
|
62
|
+
min: 0,
|
|
63
|
+
max: 1,
|
|
64
|
+
description: "sprite initial alpha value (default 1)",
|
|
65
|
+
},
|
|
66
|
+
onAnchorTransformationEnd: {
|
|
67
|
+
action: "onAnchorTransformationEnd",
|
|
68
|
+
description:
|
|
69
|
+
"on transforamtion end the event is fire callback with latest sprite transformation properties.",
|
|
70
|
+
},
|
|
71
|
+
pointerdown: {
|
|
72
|
+
action: "pointerdown",
|
|
73
|
+
description: "pointerdown event",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
} satisfies Meta<typeof PixiVideoSprite>;
|
|
77
|
+
|
|
78
|
+
export default meta;
|
|
79
|
+
type Story = StoryObj<typeof meta>;
|
|
80
|
+
|
|
81
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
82
|
+
export const Normal: Story = {
|
|
83
|
+
render: (args: any) => (
|
|
84
|
+
<AppStateContextProvider {...args}>
|
|
85
|
+
<PixiVideoSprite {...args} />
|
|
86
|
+
</AppStateContextProvider>
|
|
87
|
+
),
|
|
88
|
+
args: {
|
|
89
|
+
uniqueId: "oceanv1", // uniqueId of the sprite
|
|
90
|
+
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4",
|
|
91
|
+
transformation: {
|
|
92
|
+
x: 290,
|
|
93
|
+
y: 250,
|
|
94
|
+
width: 550,
|
|
95
|
+
height: 400,
|
|
96
|
+
anchor: 0.5,
|
|
97
|
+
rotation: 0,
|
|
98
|
+
alpha: 1,
|
|
99
|
+
scale: 1,
|
|
100
|
+
tint: 0xffffff,
|
|
101
|
+
blendMode: 0,
|
|
102
|
+
colorCorrection: {},
|
|
103
|
+
},
|
|
104
|
+
applyTransformer: false,
|
|
105
|
+
startAt: 0,
|
|
106
|
+
endAt: 10,
|
|
107
|
+
frameStartAt: 0,
|
|
108
|
+
frameEndAt: 10,
|
|
109
|
+
initialAlpha: 1,
|
|
110
|
+
mute: false,
|
|
111
|
+
locked: false,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const FadeIn: Story = {
|
|
116
|
+
render: (args: any) => (
|
|
117
|
+
<AppStateContextProvider {...args}>
|
|
118
|
+
<PixiVideoSprite {...args} />
|
|
119
|
+
</AppStateContextProvider>
|
|
120
|
+
),
|
|
121
|
+
args: {
|
|
122
|
+
uniqueId: "ForBiggerBlazes002", // uniqueId of the sprite
|
|
123
|
+
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4",
|
|
124
|
+
transformation: {
|
|
125
|
+
x: 100,
|
|
126
|
+
y: 100,
|
|
127
|
+
width: 150,
|
|
128
|
+
height: 150,
|
|
129
|
+
anchor: 0.5,
|
|
130
|
+
rotation: 0,
|
|
131
|
+
alpha: 1,
|
|
132
|
+
scale: 1,
|
|
133
|
+
tint: 0xffffff,
|
|
134
|
+
blendMode: 0,
|
|
135
|
+
animation: "FADE_IN",
|
|
136
|
+
colorCorrection: {},
|
|
137
|
+
},
|
|
138
|
+
applyTransformer: false,
|
|
139
|
+
startAt: 0,
|
|
140
|
+
endAt: 10,
|
|
141
|
+
frameStartAt: 0,
|
|
142
|
+
frameEndAt: 10,
|
|
143
|
+
initialAlpha: 0,
|
|
144
|
+
mute: false,
|
|
145
|
+
locked: false,
|
|
146
|
+
},
|
|
147
|
+
};
|