reacthub-pixitweenjs 0.2.5 → 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.
- package/.storybook/preview.tsx +6 -0
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/package.json +4 -1
- package/src/components/PixiAudioSprite/PixiAudioSprite.tsx +5 -15
- package/src/components/PixiGifSprite/PixiGifSprite.tsx +10 -89
- package/src/components/PixiImageSprite/PixiImageSprite.tsx +3 -34
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +2 -2
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +3 -35
- package/src/components/PixiTextSprite/PixiTextSprite.stories.tsx +176 -0
- package/src/components/PixiTextSprite/PixiTextSprite.tsx +540 -0
- package/src/components/PixiTextSprite/index.ts +1 -0
- package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +9 -62
- package/src/main.tsx +8 -7
- package/src/providers/GsapPixieContextProvider.tsx +14 -20
- package/src/stories/Installation.mdx +3 -3
- package/src/utils/AppStateProvider.tsx +3 -3
- package/src/utils/AppStateStage.tsx +1 -13
- package/src/utils/AppWrapper.tsx +4 -0
- package/src/utils/GsapAnim.tsx +1 -7
- package/src/utils/InteractionManager.tsx +36 -0
- package/src/utils/PixiTransformer.tsx +68 -3
- package/src/utils/VideoSeekBar.tsx +4 -11
- package/src/hooks/usePixiTransformer.tsx +0 -168
package/.storybook/preview.tsx
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AppWrapper } from "../src/utils/AppWrapper";
|
|
3
|
+
import whyDidYouRender from "@welldone-software/why-did-you-render";
|
|
4
|
+
|
|
5
|
+
whyDidYouRender(React, {
|
|
6
|
+
trackAllPureComponents: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
3
9
|
/** @type { import('@storybook/react').Preview } */
|
|
4
10
|
const preview = {
|
|
5
11
|
parameters: {
|
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.6](https://github.com/khanzzirfan/reacthub-pixitweenjs/compare/v0.2.5...v0.2.6) (2023-08-25)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* added text , gif and svg sprites ([290e6fd](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/290e6fda45ad4954c9ca767945c0863362326af4))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* updated pixi svg sprite ([6fe3619](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/6fe3619e0eb9faf0a46d10de7154ad428a21e188))
|
|
16
|
+
* updated pixi text editor ([d4cd8d9](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/d4cd8d97b53fa6210919cd641bfa74d4f7d93f84))
|
|
17
|
+
|
|
5
18
|
### [0.2.5](https://github.com/khanzzirfan/reacthub-pixitweenjs/compare/v0.2.4...v0.2.5) (2023-08-23)
|
|
6
19
|
|
|
7
20
|
|
package/README.md
CHANGED
|
@@ -37,4 +37,4 @@ PixiTweenJs is designed to help you build animated time-controlled canvas elemen
|
|
|
37
37
|
|
|
38
38
|
## Usage
|
|
39
39
|
|
|
40
|
-
Visit the [storybook](https://
|
|
40
|
+
Visit the [storybook](https://62ea8f8fe832236b40182334-qwuvdhldjp.chromatic.com/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reacthub-pixitweenjs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
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",
|
|
@@ -55,12 +55,14 @@
|
|
|
55
55
|
"@testing-library/react": "^14.0.0",
|
|
56
56
|
"@types/dotenv": "^8.2.0",
|
|
57
57
|
"@types/howler": "^2.2.8",
|
|
58
|
+
"@types/quill": "^2.0.10",
|
|
58
59
|
"@types/react": "^18.2.15",
|
|
59
60
|
"@types/react-dom": "^18.2.7",
|
|
60
61
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
61
62
|
"@typescript-eslint/parser": "^5.62.0",
|
|
62
63
|
"@vitejs/plugin-react": "^4.0.3",
|
|
63
64
|
"@vitejs/plugin-react-swc": "^3.3.2",
|
|
65
|
+
"@welldone-software/why-did-you-render": "^7.0.1",
|
|
64
66
|
"chromatic": "^6.7.3",
|
|
65
67
|
"debug": "^4.3.4",
|
|
66
68
|
"dotenv": "^16.0.1",
|
|
@@ -83,6 +85,7 @@
|
|
|
83
85
|
"pixi-svg": "^3.2.0",
|
|
84
86
|
"pixi.js": "^7.2.3",
|
|
85
87
|
"prop-types": "^15.8.1",
|
|
88
|
+
"quill": "^1.3.7",
|
|
86
89
|
"react": "^18.2.0",
|
|
87
90
|
"react-custom-events": "^1.1.1",
|
|
88
91
|
"react-dom": "^18.2.0",
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
GsapPixieContext,
|
|
7
7
|
Events,
|
|
8
8
|
} from "../../providers/GsapPixieContextProvider";
|
|
9
|
-
import { Container
|
|
9
|
+
import { Container } from "@pixi/react";
|
|
10
10
|
import { useCustomEventListener } from "react-custom-events";
|
|
11
11
|
import gsap from "gsap";
|
|
12
12
|
import { Sound } from "@pixi/sound";
|
|
@@ -46,7 +46,7 @@ const PixiAudioSprite: React.FC<PixiAudioSpriteProps> = (props) => {
|
|
|
46
46
|
isDragging: false,
|
|
47
47
|
};
|
|
48
48
|
//// State
|
|
49
|
-
const [
|
|
49
|
+
const [, setIsMounted] = React.useState(false);
|
|
50
50
|
|
|
51
51
|
const audioStateRef = useRef<AudioState>(initialState);
|
|
52
52
|
|
|
@@ -61,9 +61,8 @@ const PixiAudioSprite: React.FC<PixiAudioSpriteProps> = (props) => {
|
|
|
61
61
|
|
|
62
62
|
/// 1001
|
|
63
63
|
// console.log("contxt Values", tl);
|
|
64
|
-
const { uniqueId, src, startAt, endAt, mute, speed
|
|
64
|
+
const { uniqueId, src, startAt, endAt, mute, speed } = props;
|
|
65
65
|
|
|
66
|
-
const app = useApp();
|
|
67
66
|
const audioContainerRef = React.useRef<Sound>(null);
|
|
68
67
|
|
|
69
68
|
/** Adding custom event listners */
|
|
@@ -94,15 +93,6 @@ const PixiAudioSprite: React.FC<PixiAudioSpriteProps> = (props) => {
|
|
|
94
93
|
}
|
|
95
94
|
};
|
|
96
95
|
|
|
97
|
-
const gsapOnPause = (startAt: number) => {
|
|
98
|
-
if (containerRef.current) {
|
|
99
|
-
console.log("audio gsapOnStart", startAt);
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
audioContainerRef.current?.pause();
|
|
102
|
-
audioStateRef.current.isPlaying = false;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
96
|
const gsapOnComplete = () => {
|
|
107
97
|
if (containerRef.current) {
|
|
108
98
|
console.log("audio gsapOnStart", startAt);
|
|
@@ -131,7 +121,7 @@ const PixiAudioSprite: React.FC<PixiAudioSpriteProps> = (props) => {
|
|
|
131
121
|
}
|
|
132
122
|
};
|
|
133
123
|
|
|
134
|
-
const onInterrupt = (
|
|
124
|
+
const onInterrupt = () => {};
|
|
135
125
|
|
|
136
126
|
useEffect(() => {
|
|
137
127
|
let ctx = gsap.context(() => {});
|
|
@@ -178,7 +168,7 @@ const PixiAudioSprite: React.FC<PixiAudioSpriteProps> = (props) => {
|
|
|
178
168
|
}, [mute, speed]);
|
|
179
169
|
|
|
180
170
|
const onSoundLoaded = React.useCallback(
|
|
181
|
-
(
|
|
171
|
+
(_: any, sound: Sound | undefined) => {
|
|
182
172
|
//@ts-ignore
|
|
183
173
|
audioContainerRef.current = sound;
|
|
184
174
|
audioStateRef.current.loaded = true;
|
|
@@ -5,8 +5,7 @@ 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,
|
|
9
|
-
import { AdjustmentFilter } from "@pixi/filter-adjustment";
|
|
8
|
+
import { Container, useApp, Graphics } from "@pixi/react";
|
|
10
9
|
import * as PIXI from "pixi.js";
|
|
11
10
|
import gsap from "gsap";
|
|
12
11
|
import { useWorkerParser, usePlayerState } from "@react-gifs/tools";
|
|
@@ -72,42 +71,6 @@ type PixiGifSpriteProps = {
|
|
|
72
71
|
onAnchorTransformationEnd?: (endData: any) => void;
|
|
73
72
|
};
|
|
74
73
|
|
|
75
|
-
type EffectFunc = () => void;
|
|
76
|
-
type Deps = ReadonlyArray<unknown>;
|
|
77
|
-
|
|
78
|
-
const Filters = withFilters(Container, {
|
|
79
|
-
blur: PIXI.filters.BlurFilter,
|
|
80
|
-
adjust: AdjustmentFilter,
|
|
81
|
-
matrix: PIXI.filters.ColorMatrixFilter,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
/** filter config */
|
|
85
|
-
const config = {
|
|
86
|
-
dot: {
|
|
87
|
-
scale: 1,
|
|
88
|
-
angle: 5,
|
|
89
|
-
},
|
|
90
|
-
blur: {
|
|
91
|
-
blur: 0,
|
|
92
|
-
quality: 4,
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/** CYAN Filters */
|
|
97
|
-
const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
98
|
-
|
|
99
|
-
const initialState = {
|
|
100
|
-
isPlaying: false,
|
|
101
|
-
progress: 0,
|
|
102
|
-
speed: 1,
|
|
103
|
-
isMuted: false,
|
|
104
|
-
isWaiting: false,
|
|
105
|
-
loaded: false,
|
|
106
|
-
size: { width: 50, height: 50 },
|
|
107
|
-
play: false,
|
|
108
|
-
current: false,
|
|
109
|
-
};
|
|
110
|
-
|
|
111
74
|
/**
|
|
112
75
|
* PixiGifSprite Component is used to render gif image
|
|
113
76
|
* @param props Gif Sprite props
|
|
@@ -120,15 +83,14 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
120
83
|
const [gifFrameObject, setGifFrameObject] = React.useState<
|
|
121
84
|
PIXI.FrameObject[]
|
|
122
85
|
>([]);
|
|
123
|
-
const [
|
|
124
|
-
const [
|
|
86
|
+
const [, setCurrentFrame] = useState<number>(0);
|
|
87
|
+
const [, setIsComplete] = useState<boolean>(false);
|
|
125
88
|
|
|
126
89
|
const [isDragging, setIsDragging] = useState(false);
|
|
127
|
-
const [
|
|
90
|
+
const [, setIsMouseOverTransformer] = useState(false);
|
|
128
91
|
|
|
129
92
|
const [gifState, update] = usePlayerState({ autoPlay: false });
|
|
130
93
|
const graphicRef = React.useRef<PIXI.Graphics>(null);
|
|
131
|
-
const gifStatusRef = React.useRef(false);
|
|
132
94
|
|
|
133
95
|
console.log("allProps", props);
|
|
134
96
|
//// Refs
|
|
@@ -144,13 +106,7 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
144
106
|
/// 1001
|
|
145
107
|
console.log("contxt Values", tl);
|
|
146
108
|
console.log("gifState", gifState, gifDuration);
|
|
147
|
-
const {
|
|
148
|
-
index,
|
|
149
|
-
frames: gifFrames,
|
|
150
|
-
delays: gifDelays,
|
|
151
|
-
length,
|
|
152
|
-
loaded,
|
|
153
|
-
} = gifState;
|
|
109
|
+
const { frames: gifFrames, delays: gifDelays, loaded } = gifState;
|
|
154
110
|
|
|
155
111
|
const {
|
|
156
112
|
uniqueId,
|
|
@@ -167,10 +123,7 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
167
123
|
y,
|
|
168
124
|
rotation = 0,
|
|
169
125
|
scale,
|
|
170
|
-
anchor,
|
|
171
126
|
animation,
|
|
172
|
-
colorCorrection,
|
|
173
|
-
effect,
|
|
174
127
|
},
|
|
175
128
|
pointerdown,
|
|
176
129
|
pointerup,
|
|
@@ -182,41 +135,12 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
182
135
|
pointerout,
|
|
183
136
|
applyTransformer,
|
|
184
137
|
onAnchorTransformationEnd,
|
|
185
|
-
...restProps
|
|
186
138
|
} = props;
|
|
187
139
|
|
|
188
140
|
// color corrections
|
|
189
|
-
const {
|
|
190
|
-
enabled = false,
|
|
191
|
-
temperature = 1,
|
|
192
|
-
hue = 1,
|
|
193
|
-
contrast = 1,
|
|
194
|
-
saturation = 1,
|
|
195
|
-
exposure = 1,
|
|
196
|
-
reset,
|
|
197
|
-
sharpness = 1,
|
|
198
|
-
value = 0,
|
|
199
|
-
levels = 1,
|
|
200
|
-
luminance = 0,
|
|
201
|
-
enhance = 0,
|
|
202
|
-
blurRadius = 0,
|
|
203
|
-
red = 150,
|
|
204
|
-
green = 150,
|
|
205
|
-
blue = 150,
|
|
206
|
-
alpha = 1,
|
|
207
|
-
scaleInput = 1,
|
|
208
|
-
} = colorCorrection || {};
|
|
209
141
|
|
|
210
142
|
const app = useApp();
|
|
211
143
|
|
|
212
|
-
/** adjustment filter */
|
|
213
|
-
const adjustments = {
|
|
214
|
-
brightness: exposure,
|
|
215
|
-
contrast,
|
|
216
|
-
saturation,
|
|
217
|
-
alpha,
|
|
218
|
-
};
|
|
219
|
-
|
|
220
144
|
// load and parse gif
|
|
221
145
|
useWorkerParser(src, update);
|
|
222
146
|
|
|
@@ -270,14 +194,6 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
270
194
|
}
|
|
271
195
|
};
|
|
272
196
|
|
|
273
|
-
const gsapOnPause = (startAt: number) => {
|
|
274
|
-
// console.log(`gsap onStart ${droptype} id`, refId);
|
|
275
|
-
// console.log(elementRefs.current[refId]);
|
|
276
|
-
if (animatedSpriteRef.current) {
|
|
277
|
-
animatedSpriteRef.current.stop();
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
|
|
281
197
|
const gsapOnComplete = () => {
|
|
282
198
|
if (animatedSpriteRef.current) {
|
|
283
199
|
animatedSpriteRef.current.stop();
|
|
@@ -426,6 +342,11 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
426
342
|
pointerdown: pointerdown,
|
|
427
343
|
pointerover: pointerover,
|
|
428
344
|
pointerout: pointerout,
|
|
345
|
+
pointerup: pointerup,
|
|
346
|
+
mousedown: mousedown,
|
|
347
|
+
mouseup: mouseup,
|
|
348
|
+
mouseover: mouseover,
|
|
349
|
+
mouseout: mouseout,
|
|
429
350
|
})}
|
|
430
351
|
forwardRef={animatedSpriteRef}
|
|
431
352
|
scale={scale}
|
|
@@ -3,7 +3,7 @@ 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,
|
|
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";
|
|
@@ -65,35 +65,20 @@ type PixiImageSpriteProps = {
|
|
|
65
65
|
onAnchorTransformationEnd?: (endData: any) => void;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
type EffectFunc = () => void;
|
|
69
|
-
type Deps = ReadonlyArray<unknown>;
|
|
70
|
-
|
|
71
68
|
const Filters = withFilters(Container, {
|
|
72
69
|
blur: PIXI.filters.BlurFilter,
|
|
73
70
|
adjust: AdjustmentFilter,
|
|
74
71
|
matrix: PIXI.filters.ColorMatrixFilter,
|
|
75
72
|
});
|
|
76
73
|
|
|
77
|
-
/** filter config */
|
|
78
|
-
const config = {
|
|
79
|
-
dot: {
|
|
80
|
-
scale: 1,
|
|
81
|
-
angle: 5,
|
|
82
|
-
},
|
|
83
|
-
blur: {
|
|
84
|
-
blur: 0,
|
|
85
|
-
quality: 4,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
|
|
89
74
|
/** CYAN Filters */
|
|
90
75
|
const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
91
76
|
|
|
92
77
|
const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
|
|
93
78
|
//// State
|
|
94
79
|
const [isMounted, setIsMounted] = React.useState(false);
|
|
95
|
-
const [
|
|
96
|
-
const [
|
|
80
|
+
const [, setIsTransformerDragging] = useState(false);
|
|
81
|
+
const [, setIsMouseOverTransformer] = useState(false);
|
|
97
82
|
|
|
98
83
|
console.log("allProps", props);
|
|
99
84
|
//// Refs
|
|
@@ -133,33 +118,17 @@ const PixiImageSprite: React.FC<PixiImageSpriteProps> = (props) => {
|
|
|
133
118
|
mouseout,
|
|
134
119
|
applyTransformer,
|
|
135
120
|
onAnchorTransformationEnd,
|
|
136
|
-
...restProps
|
|
137
121
|
} = props;
|
|
138
122
|
|
|
139
123
|
// color corrections
|
|
140
124
|
const {
|
|
141
|
-
enabled = false,
|
|
142
|
-
temperature = 1,
|
|
143
|
-
hue = 1,
|
|
144
125
|
contrast = 1,
|
|
145
126
|
saturation = 1,
|
|
146
127
|
exposure = 1,
|
|
147
|
-
reset,
|
|
148
|
-
sharpness = 1,
|
|
149
|
-
value = 0,
|
|
150
|
-
levels = 1,
|
|
151
|
-
luminance = 0,
|
|
152
|
-
enhance = 0,
|
|
153
128
|
blurRadius = 0,
|
|
154
|
-
red = 150,
|
|
155
|
-
green = 150,
|
|
156
|
-
blue = 150,
|
|
157
129
|
alpha = 1,
|
|
158
|
-
scaleInput = 1,
|
|
159
130
|
} = colorCorrection || {};
|
|
160
131
|
|
|
161
|
-
const app = useApp();
|
|
162
|
-
|
|
163
132
|
/** adjustment filter */
|
|
164
133
|
const adjustments = {
|
|
165
134
|
brightness: exposure,
|
|
@@ -13,9 +13,9 @@ const meta = {
|
|
|
13
13
|
control: "text",
|
|
14
14
|
description: "uniqueId of the sprite",
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
path: {
|
|
17
17
|
control: "text",
|
|
18
|
-
description: "source of the
|
|
18
|
+
description: "source of the svg path",
|
|
19
19
|
},
|
|
20
20
|
transformation: {
|
|
21
21
|
control: "object",
|
|
@@ -73,38 +73,22 @@ type PixiSvgPathSpriteProps = {
|
|
|
73
73
|
onAnchorTransformationEnd?: (endData: any) => void;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
type EffectFunc = () => void;
|
|
77
|
-
type Deps = ReadonlyArray<unknown>;
|
|
78
|
-
|
|
79
76
|
const Filters = withFilters(Container, {
|
|
80
77
|
blur: PIXI.filters.BlurFilter,
|
|
81
78
|
adjust: AdjustmentFilter,
|
|
82
79
|
matrix: PIXI.filters.ColorMatrixFilter,
|
|
83
80
|
});
|
|
84
81
|
|
|
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
82
|
/** CYAN Filters */
|
|
98
83
|
const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
99
84
|
|
|
100
85
|
const PixiSvgPathSprite: React.FC<PixiSvgPathSpriteProps> = (props) => {
|
|
101
86
|
//// State
|
|
102
87
|
const [isMounted, setIsMounted] = React.useState(false);
|
|
103
|
-
const [
|
|
104
|
-
const [
|
|
88
|
+
const [, setIsTransformerDragging] = useState(false);
|
|
89
|
+
const [, setIsMouseOverTransformer] = useState(false);
|
|
105
90
|
const [texture, setTexture] = React.useState<any>(null);
|
|
106
91
|
|
|
107
|
-
console.log("allProps", props);
|
|
108
92
|
//// Refs
|
|
109
93
|
const imageRef = useRef<PIXI.Sprite>(null);
|
|
110
94
|
const containerRef = useRef<PIXI.Container>(null);
|
|
@@ -133,8 +117,6 @@ const PixiSvgPathSprite: React.FC<PixiSvgPathSpriteProps> = (props) => {
|
|
|
133
117
|
colorCorrection,
|
|
134
118
|
effect,
|
|
135
119
|
fill,
|
|
136
|
-
fontWeight,
|
|
137
|
-
fontStyle,
|
|
138
120
|
stroke = "none",
|
|
139
121
|
strokeWidth = 0,
|
|
140
122
|
blurRadius = 0,
|
|
@@ -148,28 +130,14 @@ const PixiSvgPathSprite: React.FC<PixiSvgPathSpriteProps> = (props) => {
|
|
|
148
130
|
mouseout,
|
|
149
131
|
applyTransformer,
|
|
150
132
|
onAnchorTransformationEnd,
|
|
151
|
-
...restProps
|
|
152
133
|
} = props;
|
|
153
134
|
|
|
154
135
|
// color corrections
|
|
155
136
|
const {
|
|
156
|
-
enabled = false,
|
|
157
|
-
temperature = 1,
|
|
158
|
-
hue = 1,
|
|
159
137
|
contrast = 1,
|
|
160
138
|
saturation = 1,
|
|
161
139
|
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
140
|
alpha = 1,
|
|
172
|
-
scaleInput = 1,
|
|
173
141
|
} = colorCorrection || {};
|
|
174
142
|
|
|
175
143
|
const app = useApp();
|
|
@@ -182,7 +150,7 @@ const PixiSvgPathSprite: React.FC<PixiSvgPathSpriteProps> = (props) => {
|
|
|
182
150
|
alpha,
|
|
183
151
|
};
|
|
184
152
|
|
|
185
|
-
const fillColor = PIXI.utils.string2hex(fill || "#262730");
|
|
153
|
+
// const fillColor = PIXI.utils.string2hex(fill || "#262730");
|
|
186
154
|
|
|
187
155
|
/** handle on tranformer onchange */
|
|
188
156
|
const handleOnTransformChange = React.useCallback(() => {
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { PixiTextSprite } 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/TextSprite",
|
|
8
|
+
component: PixiTextSprite,
|
|
9
|
+
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
argTypes: {
|
|
12
|
+
uniqueId: {
|
|
13
|
+
control: "text",
|
|
14
|
+
description: "uniqueId of the sprite",
|
|
15
|
+
},
|
|
16
|
+
text: {
|
|
17
|
+
control: "text",
|
|
18
|
+
description: "Text to be displayed",
|
|
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
|
+
pointerup: {
|
|
73
|
+
action: "pointerup",
|
|
74
|
+
description: "pointerup event",
|
|
75
|
+
},
|
|
76
|
+
onTextUpdate: {
|
|
77
|
+
action: "onTextUpdate",
|
|
78
|
+
description: "onTextUpdate event",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
} satisfies Meta<typeof PixiTextSprite>;
|
|
82
|
+
|
|
83
|
+
export default meta;
|
|
84
|
+
type Story = StoryObj<typeof meta>;
|
|
85
|
+
|
|
86
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
87
|
+
export const Normal: Story = {
|
|
88
|
+
render: (args: any) => (
|
|
89
|
+
<AppStateContextProvider {...args}>
|
|
90
|
+
<PixiTextSprite {...args} />
|
|
91
|
+
</AppStateContextProvider>
|
|
92
|
+
),
|
|
93
|
+
args: {
|
|
94
|
+
uniqueId: "TextSpritexx001", // uniqueId of the sprite
|
|
95
|
+
text: "Hello Welcome to PixiJS",
|
|
96
|
+
locked: false,
|
|
97
|
+
applyTransformer: false,
|
|
98
|
+
transformation: {
|
|
99
|
+
x: 100,
|
|
100
|
+
y: 100,
|
|
101
|
+
width: 150,
|
|
102
|
+
height: 150,
|
|
103
|
+
anchor: 0.5,
|
|
104
|
+
rotation: 0,
|
|
105
|
+
alpha: 1,
|
|
106
|
+
scale: 1,
|
|
107
|
+
blendMode: 0,
|
|
108
|
+
colorCorrection: {},
|
|
109
|
+
fill: "#00ff99",
|
|
110
|
+
fontSize: 80,
|
|
111
|
+
fontFamily: "Arial",
|
|
112
|
+
align: "center",
|
|
113
|
+
stroke: "#522d2d",
|
|
114
|
+
strokeThickness: 0,
|
|
115
|
+
letterSpacing: 0,
|
|
116
|
+
lineHeight: 0,
|
|
117
|
+
dropShadow: false,
|
|
118
|
+
dropShadowColor: "#522d2d",
|
|
119
|
+
dropShadowBlur: 0,
|
|
120
|
+
wordWrap: false,
|
|
121
|
+
wordWrapWidth: 5000000,
|
|
122
|
+
padding: 10,
|
|
123
|
+
textBaseline: "alphabetic",
|
|
124
|
+
trim: false,
|
|
125
|
+
},
|
|
126
|
+
startAt: 0,
|
|
127
|
+
endAt: 10,
|
|
128
|
+
initialAlpha: 1,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const FadeIn: Story = {
|
|
133
|
+
render: (args: any) => (
|
|
134
|
+
<AppStateContextProvider {...args}>
|
|
135
|
+
<PixiTextSprite {...args} />
|
|
136
|
+
</AppStateContextProvider>
|
|
137
|
+
),
|
|
138
|
+
args: {
|
|
139
|
+
uniqueId: "TextSprite001", // uniqueId of the sprite
|
|
140
|
+
text: "Hello Welcome to PixiJS",
|
|
141
|
+
locked: false,
|
|
142
|
+
applyTransformer: false,
|
|
143
|
+
transformation: {
|
|
144
|
+
x: 100,
|
|
145
|
+
y: 100,
|
|
146
|
+
width: 150,
|
|
147
|
+
height: 150,
|
|
148
|
+
anchor: 0.5,
|
|
149
|
+
rotation: 0,
|
|
150
|
+
alpha: 1,
|
|
151
|
+
scale: 1,
|
|
152
|
+
tint: 0xffffff,
|
|
153
|
+
blendMode: 0,
|
|
154
|
+
colorCorrection: {},
|
|
155
|
+
fill: "#00ff99",
|
|
156
|
+
fontSize: 20,
|
|
157
|
+
fontFamily: "Arial",
|
|
158
|
+
align: "center",
|
|
159
|
+
stroke: 0x000000,
|
|
160
|
+
strokeThickness: 0,
|
|
161
|
+
letterSpacing: 0,
|
|
162
|
+
lineHeight: 0,
|
|
163
|
+
dropShadow: false,
|
|
164
|
+
dropShadowColor: 0x000000,
|
|
165
|
+
dropShadowBlur: 0,
|
|
166
|
+
wordWrap: false,
|
|
167
|
+
wordWrapWidth: 100,
|
|
168
|
+
padding: 0,
|
|
169
|
+
textBaseline: "alphabetic",
|
|
170
|
+
trim: false,
|
|
171
|
+
},
|
|
172
|
+
startAt: 0,
|
|
173
|
+
endAt: 10,
|
|
174
|
+
initialAlpha: 0,
|
|
175
|
+
},
|
|
176
|
+
};
|