reacthub-pixitweenjs 0.2.2 → 0.2.4

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 (38) hide show
  1. package/.storybook/{main.js → main.ts} +9 -1
  2. package/.storybook/{preview.jsx → preview.tsx} +3 -7
  3. package/CHANGELOG.md +28 -0
  4. package/README.md +29 -80
  5. package/build-storybook.log +491 -0
  6. package/index.html +1 -1
  7. package/package.json +54 -19
  8. package/src/App.tsx +29 -0
  9. package/src/{stories/PixiImageSprite/PixiImageSprite.stories.js → components/PixiImageSprite/PixiImageSprite.stories.tsx} +25 -8
  10. package/src/components/PixiImageSprite/PixiImageSprite.tsx +346 -0
  11. package/src/components/PixiImageSprite/index.ts +1 -0
  12. package/src/hooks/usePixiTransformer.tsx +168 -0
  13. package/src/index.ts +3 -0
  14. package/src/providers/{GsapPixieContextProvider.jsx → GsapPixieContextProvider.tsx} +27 -24
  15. package/src/providers/index.ts +1 -0
  16. package/src/stories/Introduction.mdx +0 -99
  17. package/src/types/transformation.tsx +13 -0
  18. package/src/utils/AppStateProvider.tsx +70 -0
  19. package/src/utils/AppStateStage.tsx +27 -0
  20. package/src/utils/AppWrapper.tsx +43 -0
  21. package/src/utils/ContextBridge.tsx +25 -0
  22. package/src/{providers/GsapAnim.jsx → utils/GsapAnim.tsx} +35 -4
  23. package/src/utils/PixiStage.tsx +33 -0
  24. package/src/utils/VideoSeekBar.tsx +118 -0
  25. package/src/utils/useDeepEffect.tsx +23 -0
  26. package/src/vite-env.d.ts +1 -0
  27. package/tsconfig.json +37 -0
  28. package/tsconfig.node.json +10 -0
  29. package/{vite.config.js → vite.config.ts} +4 -2
  30. package/vitest.config.ts +11 -0
  31. package/src/App.jsx +0 -35
  32. package/src/index.js +0 -3
  33. package/src/providers/ContextBridge.jsx +0 -67
  34. package/src/providers/VideoSeekBar.jsx +0 -186
  35. package/src/providers/index.js +0 -3
  36. package/src/stories/PixiImageSprite/PixiImageSprite.jsx +0 -318
  37. package/src/stories/PixiImageSprite/index.js +0 -1
  38. /package/src/{main.jsx → main.tsx} +0 -0
@@ -1,318 +0,0 @@
1
- import React, { Context } from "react";
2
- import PropTypes from "prop-types";
3
- import { GsapPixieContext } from "../../providers/GsapPixieContextProvider";
4
- import { Sprite, Container, useApp, withFilters } from "@pixi/react";
5
- import { AdjustmentFilter } from "@pixi/filter-adjustment";
6
- import * as PIXI from "pixi.js";
7
- import gsap from "gsap";
8
- import isEmpty from "lodash/isEmpty";
9
- import { getAnimByName } from "../../providers/GsapAnim";
10
-
11
- const Filters = withFilters(Container, {
12
- blur: PIXI.filters.BlurFilter,
13
- adjust: AdjustmentFilter,
14
- matrix: PIXI.filters.ColorMatrixFilter,
15
- });
16
-
17
- /** filter config */
18
- const config = {
19
- dot: {
20
- scale: 1,
21
- angle: 5,
22
- },
23
- blur: {
24
- blur: 0,
25
- quality: 4,
26
- },
27
- };
28
-
29
- /** CYAN Filters */
30
- const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
31
-
32
- export const PixiImageSprite = (props) => {
33
- /// console.log("allProps", props);
34
- //// Refs
35
- const imageRef = React.useRef(null);
36
- const containerRef = React.useRef(null);
37
- const imgGroupRef = React.useRef(null);
38
-
39
- //// Context
40
- const { tl } = React.useContext(GsapPixieContext);
41
-
42
- /// 1001
43
- console.log("contxt Values", tl);
44
- const {
45
- src,
46
- startAt,
47
- endAt,
48
- initialAlpha,
49
- transformation: {
50
- x,
51
- y,
52
- width,
53
- height,
54
- anchor,
55
- animation,
56
- colorCorrection,
57
- effect,
58
- } = {},
59
- pointerdown,
60
- pointerup,
61
- mousedown,
62
- mouseup,
63
- pointerover,
64
- mouseover,
65
- mouseout,
66
- ...restProps
67
- } = props;
68
-
69
- const {
70
- enabled = false,
71
- temperature = 1,
72
- hue = 1,
73
- contrast = 1,
74
- saturation = 1,
75
- exposure = 1,
76
- reset,
77
- sharpness = 1,
78
- value = 0,
79
- levels = 1,
80
- luminance = 0,
81
- enhance = 0,
82
- blurRadius = 0,
83
- red = 150,
84
- green = 150,
85
- blue = 150,
86
- alpha = 1,
87
- scaleInput = 1,
88
- } = colorCorrection;
89
-
90
- const app = useApp();
91
- const PixiTransformer = React.useRef(null);
92
-
93
- /** adjustment filter */
94
- const adjustments = {
95
- brightness: exposure,
96
- contrast,
97
- saturation,
98
- alpha,
99
- };
100
-
101
- React.useEffect(() => {
102
- let ctx = gsap.context(() => {});
103
- if (containerRef.current && tl.current) {
104
- const data = {
105
- duration: Number(endAt) - Number(startAt),
106
- };
107
-
108
- const ease = getAnimByName(animation);
109
- ctx = gsap.context(() => {
110
- if (!isEmpty(ease.from)) {
111
- tl.current
112
- .from(containerRef.current, { ...ease.from }, startAt)
113
- .to(imgGroupRef.current, { alpha: 1, duration: 0.2 }, startAt)
114
- .from(imgGroupRef.current, { ...data }, startAt)
115
- .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
116
- } else if (!isEmpty(ease.to)) {
117
- tl.current
118
- .to(
119
- containerRef.current,
120
- { alpha: 1, duration: 0.2, ...ease.to },
121
- startAt,
122
- )
123
- .from(imgGroupRef.current, { ...data }, startAt)
124
- .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
125
- } else if (!isEmpty(ease.fromTo)) {
126
- tl.current
127
- .fromTo(
128
- containerRef.current,
129
- ease.fromTo.from,
130
- ease.fromTo.to,
131
- startAt,
132
- )
133
- .from(imgGroupRef.current, { ...data }, startAt)
134
- .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
135
- } else {
136
- tl.current
137
- .to(containerRef.current, { alpha: 1, duration: 0.01 }, startAt)
138
- .from(imgGroupRef.current, { ...data }, startAt)
139
- .to(
140
- containerRef.current,
141
- { alpha: 0, duration: 0.1 },
142
- Number(endAt) - Number(0.1),
143
- );
144
- }
145
- });
146
- }
147
- return () => ctx.revert(); // cleanup!
148
- }, [animation, startAt, endAt]);
149
-
150
- return (
151
- <Container ref={containerRef} alpha={initialAlpha}>
152
- {colorCorrection && colorCorrection.enabled ? (
153
- <Filters
154
- scale={1}
155
- blur={{ blur: blurRadius, quality: 4 }}
156
- adjust={adjustments}
157
- apply={({ matrix }) => {
158
- if (effect === "BlackAndWhite") {
159
- matrix.desaturate();
160
- } else if (effect === "Sepia") {
161
- matrix.sepia();
162
- } else if (effect === "RetroVintage") {
163
- matrix.negative();
164
- } else if (effect === "NightVision") {
165
- matrix.negative();
166
- } else if (effect === "Normal") {
167
- matrix.reset();
168
- }
169
- }}
170
- matrix={{
171
- enabled: true,
172
- matrix: CYAN,
173
- }}
174
- >
175
- <Container ref={imgGroupRef}>
176
- <Sprite
177
- image={src}
178
- width={width}
179
- height={height}
180
- anchor={anchor}
181
- ref={imageRef}
182
- x={x}
183
- y={y}
184
- interactive={true}
185
- pointerdown={pointerdown}
186
- pointerup={pointerup}
187
- pointerover={pointerover}
188
- mousedown={mousedown}
189
- mouseup={mouseup}
190
- mouseover={mouseover}
191
- mouseout={mouseout}
192
- />
193
- </Container>
194
- </Filters>
195
- ) : (
196
- <Container ref={imgGroupRef}>
197
- <Sprite
198
- image={src}
199
- width={width}
200
- height={height}
201
- anchor={anchor}
202
- ref={imageRef}
203
- x={x}
204
- y={y}
205
- interactive={true}
206
- pointerdown={pointerdown}
207
- pointerup={pointerup}
208
- pointerover={pointerover}
209
- mousedown={mousedown}
210
- mouseup={mouseup}
211
- mouseover={mouseover}
212
- mouseout={mouseout}
213
- />
214
- </Container>
215
- )}
216
- </Container>
217
- );
218
- };
219
-
220
- PixiImageSprite.propTypes = {
221
- // app background color property
222
- backgroundColor: PropTypes.string,
223
- // sprite transformation properties
224
- transformation: PropTypes.shape({
225
- x: PropTypes.number,
226
- y: PropTypes.number,
227
- width: PropTypes.number,
228
- height: PropTypes.number,
229
- anchor: PropTypes.number,
230
- rotation: PropTypes.number,
231
- alpha: PropTypes.number,
232
- scale: PropTypes.number,
233
- tint: PropTypes.number,
234
- blendMode: PropTypes.number,
235
- colorCorrection: PropTypes.shape({
236
- enabled: PropTypes.bool,
237
- temperature: PropTypes.number,
238
- hue: PropTypes.number,
239
- contrast: PropTypes.number,
240
- saturation: PropTypes.number,
241
- exposure: PropTypes.number,
242
- reset: PropTypes.bool,
243
- sharpness: PropTypes.number,
244
- value: PropTypes.number,
245
- levels: PropTypes.number,
246
- luminance: PropTypes.number,
247
- enhance: PropTypes.number,
248
- blurRadius: PropTypes.number,
249
- red: PropTypes.number,
250
- green: PropTypes.number,
251
- blue: PropTypes.number,
252
- alpha: PropTypes.number,
253
- scaleInput: PropTypes.number,
254
- }),
255
- effect: PropTypes.string,
256
- pointerdown: PropTypes.func,
257
- pointerup: PropTypes.func,
258
- pointerover: PropTypes.func,
259
- mousedown: PropTypes.func,
260
- mouseup: PropTypes.func,
261
- mouseover: PropTypes.func,
262
- mouseout: PropTypes.func,
263
- }).isRequired,
264
- // sprite initial alpha property (opacity)
265
- initialAlpha: PropTypes.number,
266
- // sprite animation properties
267
- applyTransformer: PropTypes.bool,
268
- // sprite startAt and endAt properties
269
- startAt: PropTypes.number.isRequired,
270
- // sprite startAt and endAt properties
271
- endAt: PropTypes.number.isRequired,
272
- };
273
-
274
- PixiImageSprite.defaultProps = {
275
- pointerdown: () => {},
276
- pointerup: () => {},
277
- mousedown: () => {},
278
- mouseup: () => {},
279
- pointerover: () => {},
280
- mouseover: () => {},
281
- mouseout: () => {},
282
- backgroundColor: "0x000000",
283
- transformation: {
284
- x: 0,
285
- y: 0,
286
- width: 0,
287
- height: 0,
288
- anchor: 0,
289
- rotation: 0,
290
- alpha: 1,
291
- scale: 1,
292
- tint: 0xffffff,
293
- blendMode: 0,
294
- colorCorrection: {
295
- enabled: false,
296
- temperature: 1,
297
- hue: 1,
298
- contrast: 1,
299
- saturation: 1,
300
- exposure: 1,
301
- reset: false,
302
- sharpness: 1,
303
- value: 0,
304
- levels: 1,
305
- luminance: 0,
306
- enhance: 0,
307
- blurRadius: 0,
308
- red: 150,
309
- green: 150,
310
- blue: 150,
311
- alpha: 1,
312
- scaleInput: 1,
313
- },
314
- effect: "Normal",
315
- },
316
- initialAlpha: 1,
317
- applyTransformer: false,
318
- };
@@ -1 +0,0 @@
1
- export * from "./PixiImageSprite";
File without changes