reacthub-pixitweenjs 0.2.5 → 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/.storybook/preview.tsx +6 -0
- package/CHANGELOG.md +26 -0
- package/README.md +1 -1
- package/package.json +4 -1
- package/src/components/PixiAudioSprite/PixiAudioSprite.tsx +5 -15
- package/src/components/PixiGifSprite/PixiGifSprite.stories.tsx +41 -4
- package/src/components/PixiGifSprite/PixiGifSprite.tsx +64 -95
- package/src/components/PixiImageSprite/PixiImageSprite.stories.tsx +53 -7
- package/src/components/PixiImageSprite/PixiImageSprite.tsx +27 -307
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +51 -14
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +33 -253
- package/src/components/PixiTextSprite/PixiTextSprite.stories.tsx +228 -0
- package/src/components/PixiTextSprite/PixiTextSprite.tsx +361 -0
- package/src/components/PixiTextSprite/index.ts +1 -0
- package/src/components/PixiVideoSprite/PixiVideoSprite.stories.tsx +39 -0
- package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +595 -684
- package/src/hocs/AbstractContainer.tsx +199 -0
- package/src/hocs/WithFilterContainer.tsx +159 -0
- package/src/main.tsx +8 -7
- package/src/providers/GsapPixieContextProvider.tsx +14 -20
- package/src/stories/Installation.mdx +3 -3
- 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/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
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useContext, useRef, useState } from "react";
|
|
3
|
+
import gsap from "gsap";
|
|
4
|
+
|
|
5
|
+
import { Container, withFilters } from "@pixi/react";
|
|
6
|
+
import { AdjustmentFilter } from "@pixi/filter-adjustment";
|
|
7
|
+
import * as PIXI from "pixi.js";
|
|
8
|
+
import { Effects } from "../types/Effects";
|
|
9
|
+
// import pixiTransfomer from "../utils/PixiTransformer";
|
|
10
|
+
import PixiTransformer from "../utils/PixiTransformer";
|
|
11
|
+
import { PixiBaseSpriteProps } from "../types/BaseProps";
|
|
12
|
+
import { TransformationEnd } from "../types/transformation";
|
|
13
|
+
import { GsapPixieContext } from "../providers/GsapPixieContextProvider";
|
|
14
|
+
import { getAnimByName } from "../utils/GsapAnim";
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
import isEmpty from "lodash/isEmpty";
|
|
17
|
+
|
|
18
|
+
/** CYAN Filters */
|
|
19
|
+
const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
20
|
+
|
|
21
|
+
const AbstractContainer: React.FC<PixiBaseSpriteProps> = (props) => {
|
|
22
|
+
//// State
|
|
23
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
24
|
+
const [, setIsTransformerDragging] = useState(false);
|
|
25
|
+
const [, setIsMouseOverTransformer] = useState(false);
|
|
26
|
+
|
|
27
|
+
//// Refs
|
|
28
|
+
const containerRef = useRef<PIXI.Container>(null);
|
|
29
|
+
const parentNode = useRef<PIXI.Container>(null);
|
|
30
|
+
const imgGroupRef = useRef<PIXI.Container>(null);
|
|
31
|
+
const transformerRef = useRef<PIXI.Container>(null);
|
|
32
|
+
|
|
33
|
+
//// Context
|
|
34
|
+
const { tl } = useContext(GsapPixieContext);
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
uniqueId,
|
|
38
|
+
startAt,
|
|
39
|
+
endAt,
|
|
40
|
+
initialAlpha,
|
|
41
|
+
transformation: { x, y, width, height, colorCorrection, animation, effect },
|
|
42
|
+
applyTransformer,
|
|
43
|
+
} = props;
|
|
44
|
+
|
|
45
|
+
console.log("all abstract props", props);
|
|
46
|
+
|
|
47
|
+
// color corrections
|
|
48
|
+
const {
|
|
49
|
+
contrast = 1,
|
|
50
|
+
saturation = 1,
|
|
51
|
+
brightness = 1,
|
|
52
|
+
alpha = 1,
|
|
53
|
+
blurRadius = 0,
|
|
54
|
+
} = colorCorrection || {};
|
|
55
|
+
|
|
56
|
+
/** adjustment filter */
|
|
57
|
+
const adjustments = {
|
|
58
|
+
...(brightness > 1 && { brightness: brightness }),
|
|
59
|
+
...(contrast > 1 && { contrast: contrast }),
|
|
60
|
+
...(saturation > 1 && { saturation: saturation }),
|
|
61
|
+
...(alpha !== 0 && { alpha: alpha }),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
if (containerRef.current) {
|
|
66
|
+
setIsMounted(true);
|
|
67
|
+
}
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
let ctx = gsap.context(() => {});
|
|
72
|
+
if (containerRef.current && tl.current) {
|
|
73
|
+
const data = {
|
|
74
|
+
duration: Number(endAt) - Number(startAt),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const ease = getAnimByName(animation || "None");
|
|
78
|
+
ctx = gsap.context(() => {
|
|
79
|
+
if (!isEmpty(ease.from)) {
|
|
80
|
+
tl.current
|
|
81
|
+
.from(containerRef.current, { ...ease.from }, startAt)
|
|
82
|
+
.to(imgGroupRef.current, { alpha: 1, duration: 0.2 }, startAt)
|
|
83
|
+
.from(imgGroupRef.current, { ...data }, startAt)
|
|
84
|
+
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
85
|
+
} else if (!isEmpty(ease.to)) {
|
|
86
|
+
tl.current
|
|
87
|
+
.to(
|
|
88
|
+
containerRef.current,
|
|
89
|
+
{ alpha: 1, duration: 0.2, ...ease.to },
|
|
90
|
+
startAt
|
|
91
|
+
)
|
|
92
|
+
.from(imgGroupRef.current, { ...data }, startAt)
|
|
93
|
+
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
94
|
+
} else if (!isEmpty(ease.fromTo)) {
|
|
95
|
+
tl.current
|
|
96
|
+
.fromTo(
|
|
97
|
+
containerRef.current,
|
|
98
|
+
ease.fromTo?.from,
|
|
99
|
+
ease.fromTo?.to,
|
|
100
|
+
startAt
|
|
101
|
+
)
|
|
102
|
+
.from(imgGroupRef.current, { ...data }, startAt)
|
|
103
|
+
.to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
|
|
104
|
+
} else {
|
|
105
|
+
tl.current
|
|
106
|
+
.to(containerRef.current, { alpha: 1, duration: 0.01 }, startAt)
|
|
107
|
+
.from(imgGroupRef.current, { ...data }, startAt)
|
|
108
|
+
.to(
|
|
109
|
+
containerRef.current,
|
|
110
|
+
{ alpha: 0, duration: 0.1 },
|
|
111
|
+
Number(endAt) - Number(0.1)
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return () => ctx.revert(); // cleanup!
|
|
117
|
+
}, [animation, startAt, endAt]);
|
|
118
|
+
|
|
119
|
+
/** handle on tranformer onchange */
|
|
120
|
+
const handleOnTransformChange = React.useCallback(() => {
|
|
121
|
+
setIsTransformerDragging(true);
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
// transformer to handle sprite transformation
|
|
125
|
+
const handleOnTransformEnd = React.useCallback(
|
|
126
|
+
(endData: TransformationEnd) => {
|
|
127
|
+
console.log("changeEnd", endData);
|
|
128
|
+
if (props.onAnchorTransformationEnd) {
|
|
129
|
+
console.log("running onAnchorTransformationEnd");
|
|
130
|
+
props.onAnchorTransformationEnd(endData);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
[]
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const Filters = withFilters(Container, {
|
|
137
|
+
...(blurRadius > 0 && { blur: PIXI.filters.BlurFilter }),
|
|
138
|
+
...(!isEmpty(adjustments) && { adjust: AdjustmentFilter }),
|
|
139
|
+
matrix: PIXI.filters.ColorMatrixFilter,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const isFilterOrEffectEnabled =
|
|
143
|
+
colorCorrection?.enabled || (effect && effect !== Effects.Normal);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<Container ref={parentNode}>
|
|
147
|
+
<Container
|
|
148
|
+
ref={containerRef}
|
|
149
|
+
alpha={initialAlpha}
|
|
150
|
+
position={[x, y]}
|
|
151
|
+
pivot={[x, y]}
|
|
152
|
+
width={width}
|
|
153
|
+
height={height}
|
|
154
|
+
>
|
|
155
|
+
{isFilterOrEffectEnabled && (
|
|
156
|
+
<Filters
|
|
157
|
+
scale={1}
|
|
158
|
+
blur={{ blur: blurRadius, quality: 4 }}
|
|
159
|
+
adjust={adjustments}
|
|
160
|
+
apply={({ matrix }: { matrix: any }) => {
|
|
161
|
+
if (effect === Effects.BlackAndWhite) {
|
|
162
|
+
matrix.desaturate();
|
|
163
|
+
} else if (effect === Effects.Sepia) {
|
|
164
|
+
matrix.sepia();
|
|
165
|
+
} else if (effect === Effects.RetroVintage) {
|
|
166
|
+
matrix.negative();
|
|
167
|
+
} else if (effect === Effects.NightVision) {
|
|
168
|
+
matrix.negative();
|
|
169
|
+
} else if (effect === Effects.Normal) {
|
|
170
|
+
matrix.reset();
|
|
171
|
+
}
|
|
172
|
+
}}
|
|
173
|
+
matrix={{
|
|
174
|
+
enabled: true,
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
matrix: CYAN,
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
{props.children}
|
|
180
|
+
</Filters>
|
|
181
|
+
)}
|
|
182
|
+
{!isFilterOrEffectEnabled && props.children}
|
|
183
|
+
</Container>
|
|
184
|
+
{applyTransformer && (
|
|
185
|
+
<PixiTransformer
|
|
186
|
+
pixiTransformerRef={transformerRef}
|
|
187
|
+
imageRef={containerRef}
|
|
188
|
+
isMounted={isMounted}
|
|
189
|
+
transformCommit={handleOnTransformEnd}
|
|
190
|
+
transformChange={handleOnTransformChange}
|
|
191
|
+
mouseoverEvent={setIsMouseOverTransformer}
|
|
192
|
+
uniqueId={uniqueId}
|
|
193
|
+
/>
|
|
194
|
+
)}
|
|
195
|
+
</Container>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export default AbstractContainer;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Container, withFilters } from "@pixi/react";
|
|
3
|
+
import { AdjustmentFilter } from "@pixi/filter-adjustment";
|
|
4
|
+
import * as PIXI from "pixi.js";
|
|
5
|
+
import { Effects } from "../types/Effects";
|
|
6
|
+
// import pixiTransfomer from "../utils/PixiTransformer";
|
|
7
|
+
import PixiTransformer from "../utils/PixiTransformer";
|
|
8
|
+
import { PixiBaseSpriteProps } from "../types/BaseProps";
|
|
9
|
+
import { TransformationEnd } from "../types/transformation";
|
|
10
|
+
|
|
11
|
+
const Filters = withFilters(Container, {
|
|
12
|
+
blur: PIXI.filters.BlurFilter,
|
|
13
|
+
adjust: AdjustmentFilter,
|
|
14
|
+
matrix: PIXI.filters.ColorMatrixFilter,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/** CYAN Filters */
|
|
18
|
+
const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
|
|
19
|
+
|
|
20
|
+
const withFilterContainer = <P extends object>(
|
|
21
|
+
WrappedComponent: React.ComponentType<P & PixiBaseSpriteProps>
|
|
22
|
+
) => {
|
|
23
|
+
return class WithPixi extends React.Component<P & PixiBaseSpriteProps> {
|
|
24
|
+
imageRef: React.RefObject<PIXI.Sprite>;
|
|
25
|
+
containerRef: React.RefObject<PIXI.Container<PIXI.DisplayObject>>;
|
|
26
|
+
parentNode: React.RefObject<PIXI.Container<PIXI.DisplayObject>>;
|
|
27
|
+
imgGroupRef: React.RefObject<PIXI.Container<PIXI.DisplayObject>>;
|
|
28
|
+
transformerRef: React.RefObject<PIXI.Container<PIXI.DisplayObject>>;
|
|
29
|
+
isMounted: React.RefObject<boolean>;
|
|
30
|
+
|
|
31
|
+
constructor(props: P & PixiBaseSpriteProps) {
|
|
32
|
+
super(props);
|
|
33
|
+
// create refs
|
|
34
|
+
this.imageRef = React.createRef<PIXI.Sprite>();
|
|
35
|
+
this.containerRef = React.createRef<PIXI.Container>();
|
|
36
|
+
this.parentNode = React.createRef<PIXI.Container>();
|
|
37
|
+
this.imgGroupRef = React.createRef<PIXI.Container>();
|
|
38
|
+
this.transformerRef = React.createRef<PIXI.Container>();
|
|
39
|
+
this.isMounted = React.createRef<boolean>();
|
|
40
|
+
// implement ismounted state
|
|
41
|
+
this.state = {
|
|
42
|
+
isMounted: false,
|
|
43
|
+
isTransformerDragging: false,
|
|
44
|
+
isMouseOverTransformer: false,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
componentDidMount() {
|
|
49
|
+
/// this.app.stage.addChild(new PIXI.Sprite(PIXI.Texture.WHITE));
|
|
50
|
+
// console.log("this.app.stage", this.app.stage);
|
|
51
|
+
// set isMounted to true
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
this.isMounted.current = true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
componentWillUnmount() {
|
|
57
|
+
// set isMounted to false
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
this.isMounted.current = false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** handle on tranformer onchange */
|
|
63
|
+
handleOnTransformChange = () => {
|
|
64
|
+
this.setState({ isTransformerDragging: true });
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// transformer to handle sprite transformation
|
|
68
|
+
handleOnTransformEnd = (endData: TransformationEnd) => {
|
|
69
|
+
console.log("changeEnd", endData);
|
|
70
|
+
const { onAnchorTransformationEnd } = this.props;
|
|
71
|
+
if (onAnchorTransformationEnd) {
|
|
72
|
+
console.log("running onAnchorTransformationEnd");
|
|
73
|
+
onAnchorTransformationEnd(endData);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// handle mouse over transformer state
|
|
78
|
+
setIsMouseOverTransformer = (isMouseOverTransformer: boolean) => {
|
|
79
|
+
this.setState({ isMouseOverTransformer });
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
render() {
|
|
83
|
+
const {
|
|
84
|
+
uniqueId,
|
|
85
|
+
initialAlpha,
|
|
86
|
+
transformation: { x, y, width, height, colorCorrection, effect },
|
|
87
|
+
applyTransformer,
|
|
88
|
+
} = this.props;
|
|
89
|
+
|
|
90
|
+
// color corrections
|
|
91
|
+
const {
|
|
92
|
+
contrast = 1,
|
|
93
|
+
saturation = 1,
|
|
94
|
+
exposure = 1,
|
|
95
|
+
alpha = 1,
|
|
96
|
+
blurRadius = 0,
|
|
97
|
+
} = colorCorrection || {};
|
|
98
|
+
|
|
99
|
+
/** adjustment filter */
|
|
100
|
+
const adjustments = {
|
|
101
|
+
brightness: exposure,
|
|
102
|
+
contrast,
|
|
103
|
+
saturation,
|
|
104
|
+
alpha,
|
|
105
|
+
};
|
|
106
|
+
return (
|
|
107
|
+
<Container ref={this.parentNode}>
|
|
108
|
+
<Container
|
|
109
|
+
ref={this.containerRef}
|
|
110
|
+
alpha={initialAlpha}
|
|
111
|
+
position={[x, y]}
|
|
112
|
+
pivot={[x, y]}
|
|
113
|
+
width={width}
|
|
114
|
+
height={height}
|
|
115
|
+
>
|
|
116
|
+
<Filters
|
|
117
|
+
scale={1}
|
|
118
|
+
blur={{ blur: blurRadius, quality: 4 }}
|
|
119
|
+
adjust={adjustments}
|
|
120
|
+
apply={({ matrix }: { matrix: any }) => {
|
|
121
|
+
if (effect === Effects.BlackAndWhite) {
|
|
122
|
+
matrix.desaturate();
|
|
123
|
+
} else if (effect === Effects.Sepia) {
|
|
124
|
+
matrix.sepia();
|
|
125
|
+
} else if (effect === Effects.RetroVintage) {
|
|
126
|
+
matrix.negative();
|
|
127
|
+
} else if (effect === Effects.NightVision) {
|
|
128
|
+
matrix.negative();
|
|
129
|
+
} else if (effect === Effects.Normal) {
|
|
130
|
+
matrix.reset();
|
|
131
|
+
}
|
|
132
|
+
}}
|
|
133
|
+
matrix={{
|
|
134
|
+
enabled: true,
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
matrix: CYAN,
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<WrappedComponent {...this.props} />
|
|
140
|
+
</Filters>
|
|
141
|
+
</Container>
|
|
142
|
+
{applyTransformer && (
|
|
143
|
+
<PixiTransformer
|
|
144
|
+
pixiTransformerRef={this.transformerRef}
|
|
145
|
+
imageRef={this.containerRef}
|
|
146
|
+
isMounted={this.isMounted.current || false}
|
|
147
|
+
transformCommit={this.handleOnTransformEnd}
|
|
148
|
+
transformChange={this.handleOnTransformChange}
|
|
149
|
+
mouseoverEvent={this.setIsMouseOverTransformer}
|
|
150
|
+
uniqueId={uniqueId}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
</Container>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export default withFilterContainer;
|
package/src/main.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import ReactDOM from
|
|
3
|
-
import App from
|
|
4
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as ReactDOM from "react-dom/client";
|
|
3
|
+
import App from "./App";
|
|
4
|
+
import "./index.css";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
ReactDOM.createRoot(document.getElementById("root")).render(
|
|
7
8
|
<React.StrictMode>
|
|
8
9
|
<App />
|
|
9
|
-
</React.StrictMode
|
|
10
|
-
)
|
|
10
|
+
</React.StrictMode>
|
|
11
|
+
);
|
|
@@ -48,7 +48,6 @@ const GsapPixieContextProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
48
48
|
children,
|
|
49
49
|
}) => {
|
|
50
50
|
const [play, setPlay] = useState<boolean>(false);
|
|
51
|
-
const [frameNumber, setFrameNumber] = useState<number>(0);
|
|
52
51
|
const [isDragging, setIsDragging] = useState<boolean>(false);
|
|
53
52
|
const [internalDuration, setInternalDuration] = useState<number>(0);
|
|
54
53
|
const [totalDuration, setTotalDuration] = useState<number>(0);
|
|
@@ -58,9 +57,9 @@ const GsapPixieContextProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
58
57
|
const gsapCtx = useRef<any>();
|
|
59
58
|
const playerTimeRef = useRef<number>(0.001);
|
|
60
59
|
|
|
61
|
-
const parentElementRef = useRef<any>();
|
|
60
|
+
// const parentElementRef = useRef<any>();
|
|
62
61
|
// передаем предка анимируемых элементов
|
|
63
|
-
const q = gsap.utils.selector(parentElementRef);
|
|
62
|
+
// const q = gsap.utils.selector(parentElementRef);
|
|
64
63
|
|
|
65
64
|
useLayoutEffect(() => {
|
|
66
65
|
gsapCtx.current = gsap.context(() => {
|
|
@@ -75,7 +74,7 @@ const GsapPixieContextProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
75
74
|
return () => gsapCtx.current.revert();
|
|
76
75
|
}, []);
|
|
77
76
|
|
|
78
|
-
gsap.ticker.add((
|
|
77
|
+
gsap.ticker.add(() => {
|
|
79
78
|
// console.log("timeframe", time, deltaTime, frame);
|
|
80
79
|
// setFrameNumber(frame);
|
|
81
80
|
if (tl.current && getTimelineDuration) {
|
|
@@ -86,11 +85,11 @@ const GsapPixieContextProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
86
85
|
const onUpdate = useCallback(() => {
|
|
87
86
|
/// console.log("update event callback");
|
|
88
87
|
const timeline = tl.current;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (playerTimeRef.current) {
|
|
92
|
-
|
|
93
|
-
}
|
|
88
|
+
let now = timeline.time();
|
|
89
|
+
// let elapsedTime;
|
|
90
|
+
// if (playerTimeRef.current) {
|
|
91
|
+
// elapsedTime = now - playerTimeRef.current;
|
|
92
|
+
// }
|
|
94
93
|
// console.log(`elapseTime :${elapsedTime} and frame: ${frameNumber}`);
|
|
95
94
|
//time = now;
|
|
96
95
|
playerTimeRef.current = now;
|
|
@@ -154,11 +153,6 @@ const GsapPixieContextProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
154
153
|
}
|
|
155
154
|
}, [play]);
|
|
156
155
|
|
|
157
|
-
const addTotalDuration = (duration: number) => {
|
|
158
|
-
const timeline = tl.current;
|
|
159
|
-
timeline.totalDuration(duration);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
156
|
const handleReset = useCallback(() => {
|
|
163
157
|
const timeline = tl.current;
|
|
164
158
|
|
|
@@ -188,10 +182,10 @@ const GsapPixieContextProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
188
182
|
timeline.seek(4);
|
|
189
183
|
}, []);
|
|
190
184
|
|
|
191
|
-
const setTimelineDuration = useCallback(() => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}, []);
|
|
185
|
+
// const setTimelineDuration = useCallback(() => {
|
|
186
|
+
// const timeline = tl.current;
|
|
187
|
+
// timeline.totalDuration(3);
|
|
188
|
+
// }, []);
|
|
195
189
|
|
|
196
190
|
const getTimelineDuration = useCallback(() => {
|
|
197
191
|
const timeline = tl.current;
|
|
@@ -214,12 +208,12 @@ const GsapPixieContextProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
214
208
|
};
|
|
215
209
|
|
|
216
210
|
/** Event listener dragging */
|
|
217
|
-
useCustomEventListener(Events.DRAGGING_START, (
|
|
211
|
+
useCustomEventListener(Events.DRAGGING_START, () => {
|
|
218
212
|
console.log("dragging start");
|
|
219
213
|
setIsDragging(true);
|
|
220
214
|
});
|
|
221
215
|
|
|
222
|
-
useCustomEventListener(Events.DRAGGING_END, (
|
|
216
|
+
useCustomEventListener(Events.DRAGGING_END, () => {
|
|
223
217
|
setIsDragging(false);
|
|
224
218
|
console.log("dragging end");
|
|
225
219
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export enum Animations {
|
|
2
|
+
FADE_IN = "FADE_IN",
|
|
3
|
+
FADE_OUT = "FADE_OUT",
|
|
4
|
+
FADE_IN_OUT = "FADE_IN_OUT",
|
|
5
|
+
SLIDE_IN_LEFT = "SLIDE_IN_LEFT",
|
|
6
|
+
SLIDE_IN_RIGHT = "SLIDE_IN_RIGHT",
|
|
7
|
+
SLIDE_IN_TOP = "SLIDE_IN_TOP",
|
|
8
|
+
SLIDE_IN_BOTTOM = "SLIDE_IN_BOTTOM",
|
|
9
|
+
SLIDE_OUT_LEFT = "SLIDE_OUT_LEFT",
|
|
10
|
+
SLIDE_OUT_RIGHT = "SLIDE_OUT_RIGHT",
|
|
11
|
+
SLIDE_OUT_TOP = "SLIDE_OUT_TOP",
|
|
12
|
+
SLIDE_OUT_BOTTOM = "SLIDE_OUT_BOTTOM",
|
|
13
|
+
ZOOM_IN = "ZOOM_IN",
|
|
14
|
+
ZOOM_OUT = "ZOOM_OUT",
|
|
15
|
+
ZOOM_IN_OUT = "ZOOM_IN_OUT",
|
|
16
|
+
BOUNCE_IN = "BOUNCE_IN",
|
|
17
|
+
BOUNCE_OUT = "BOUNCE_OUT",
|
|
18
|
+
BOUNCE_IN_OUT = "BOUNCE_IN_OUT",
|
|
19
|
+
ELASTIC_IN = "ELASTIC_IN",
|
|
20
|
+
ELASTIC_OUT = "ELASTIC_OUT",
|
|
21
|
+
ELASTIC_IN_OUT = "ELASTIC_IN_OUT",
|
|
22
|
+
BACK_IN = "BACK_IN",
|
|
23
|
+
BACK_OUT = "BACK_OUT",
|
|
24
|
+
BACK_IN_OUT = "BACK_IN_OUT",
|
|
25
|
+
CIRCULAR_IN = "CIRCULAR_IN",
|
|
26
|
+
CIRCULAR_OUT = "CIRCULAR_OUT",
|
|
27
|
+
CIRCULAR_IN_OUT = "CIRCULAR_IN_OUT",
|
|
28
|
+
EXPO_IN = "EXPO_IN",
|
|
29
|
+
EXPO_OUT = "EXPO_OUT",
|
|
30
|
+
EXPO_IN_OUT = "EXPO_IN_OUT",
|
|
31
|
+
SINE_IN = "SINE_IN",
|
|
32
|
+
SINE_OUT = "SINE_OUT",
|
|
33
|
+
SINE_IN_OUT = "SINE_IN_OUT",
|
|
34
|
+
BOUNCE = "BOUNCE",
|
|
35
|
+
ELASTIC = "ELASTIC",
|
|
36
|
+
BACK = "BACK",
|
|
37
|
+
CIRCULAR = "CIRCULAR",
|
|
38
|
+
EXPO = "EXPO",
|
|
39
|
+
SINE = "SINE",
|
|
40
|
+
// Custom
|
|
41
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Effects } from "./Effects";
|
|
2
|
+
|
|
3
|
+
export interface PixiBaseSpriteProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
uniqueId: string;
|
|
6
|
+
src?: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
startAt: number;
|
|
10
|
+
endAt: number;
|
|
11
|
+
initialAlpha: number;
|
|
12
|
+
transformation: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
anchor: number;
|
|
18
|
+
rotation?: number;
|
|
19
|
+
alpha?: number;
|
|
20
|
+
scale?: number | [number, number];
|
|
21
|
+
tint?: number;
|
|
22
|
+
blendMode?: number;
|
|
23
|
+
animation?: string;
|
|
24
|
+
colorCorrection?: {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
temperature?: number;
|
|
27
|
+
hue?: number;
|
|
28
|
+
contrast?: number;
|
|
29
|
+
saturation?: number;
|
|
30
|
+
brightness?: number;
|
|
31
|
+
exposure?: number;
|
|
32
|
+
reset?: boolean;
|
|
33
|
+
sharpness?: number;
|
|
34
|
+
value?: number;
|
|
35
|
+
levels?: number;
|
|
36
|
+
luminance?: number;
|
|
37
|
+
enhance?: number;
|
|
38
|
+
blurRadius?: number;
|
|
39
|
+
red?: number;
|
|
40
|
+
green?: number;
|
|
41
|
+
blue?: number;
|
|
42
|
+
alpha?: number;
|
|
43
|
+
scaleInput?: number;
|
|
44
|
+
};
|
|
45
|
+
effect?: Effects;
|
|
46
|
+
};
|
|
47
|
+
pointerdown?: () => void;
|
|
48
|
+
pointerup?: () => void;
|
|
49
|
+
mousedown?: () => void;
|
|
50
|
+
mouseup?: () => void;
|
|
51
|
+
pointerover?: () => void;
|
|
52
|
+
mouseover?: () => void;
|
|
53
|
+
mouseout?: () => void;
|
|
54
|
+
applyTransformer?: boolean;
|
|
55
|
+
onAnchorTransformationEnd?: (endData: any) => void;
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export enum BlendModes {
|
|
2
|
+
NORMAL = 0,
|
|
3
|
+
ADD = 1,
|
|
4
|
+
MULTIPLY = 2,
|
|
5
|
+
SCREEN = 3,
|
|
6
|
+
OVERLAY = 4,
|
|
7
|
+
DARKEN = 5,
|
|
8
|
+
LIGHTEN = 6,
|
|
9
|
+
COLOR_DODGE = 7,
|
|
10
|
+
COLOR_BURN = 8,
|
|
11
|
+
HARD_LIGHT = 9,
|
|
12
|
+
SOFT_LIGHT = 10,
|
|
13
|
+
DIFFERENCE = 11,
|
|
14
|
+
EXCLUSION = 12,
|
|
15
|
+
HUE = 13,
|
|
16
|
+
SATURATION = 14,
|
|
17
|
+
COLOR = 15,
|
|
18
|
+
LUMINOSITY = 16,
|
|
19
|
+
}
|
|
@@ -27,7 +27,7 @@ export const AppStateContextProvider: React.FC<
|
|
|
27
27
|
const onAnchorTransformationEnd = React.useCallback(
|
|
28
28
|
(data: TransformationEnd) => {
|
|
29
29
|
console.log("onAnchorTransformationEnd", data);
|
|
30
|
-
const {
|
|
30
|
+
const { transformation } = data;
|
|
31
31
|
const newAppState = {
|
|
32
32
|
...appStateRef.current,
|
|
33
33
|
transformation: {
|
|
@@ -41,9 +41,9 @@ export const AppStateContextProvider: React.FC<
|
|
|
41
41
|
[]
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
const onMouseOverSprite = React.useCallback((
|
|
44
|
+
const onMouseOverSprite = React.useCallback(() => {}, []);
|
|
45
45
|
|
|
46
|
-
const onClickSprite = React.useCallback((
|
|
46
|
+
const onClickSprite = React.useCallback(() => {}, []);
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
49
|
<>
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import ContextBridge from "./ContextBridge";
|
|
3
|
-
import { AppStateContext } from "./AppStateProvider";
|
|
4
2
|
import { Container as PixiContainer } from "@pixi/react";
|
|
5
3
|
|
|
6
4
|
interface AppStateStageProps {
|
|
@@ -11,17 +9,7 @@ const AppStateStage: React.FC<AppStateStageProps> = ({
|
|
|
11
9
|
children,
|
|
12
10
|
...props
|
|
13
11
|
}) => {
|
|
14
|
-
return
|
|
15
|
-
<ContextBridge
|
|
16
|
-
Context={AppStateContext}
|
|
17
|
-
render={(children: React.ReactNode) => (
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
<PixiContainer {...props}>{children}</PixiContainer>
|
|
20
|
-
)}
|
|
21
|
-
>
|
|
22
|
-
{children}
|
|
23
|
-
</ContextBridge>
|
|
24
|
-
);
|
|
12
|
+
return <PixiContainer {...props}>{children}</PixiContainer>;
|
|
25
13
|
};
|
|
26
14
|
|
|
27
15
|
export default AppStateStage;
|
package/src/utils/AppWrapper.tsx
CHANGED
|
@@ -18,9 +18,13 @@ export const AppWrapper: React.FC<AppProps> = ({
|
|
|
18
18
|
const backgroundColorx = PIXI.utils.string2hex(backgroundColor || "#2D2E3C");
|
|
19
19
|
const width = 600;
|
|
20
20
|
const height = 500;
|
|
21
|
+
const quillEditorRef = React.useRef<HTMLDivElement>(null);
|
|
22
|
+
|
|
21
23
|
/// color: 0x1099bb,
|
|
22
24
|
return (
|
|
23
25
|
<div className="App">
|
|
26
|
+
<div id="note-editor" ref={quillEditorRef}></div>
|
|
27
|
+
<div id="lottieroot"></div>
|
|
24
28
|
<GsapPixieContextProvider>
|
|
25
29
|
<ChakraProvider>
|
|
26
30
|
<Flex flexDir={"column"}>
|
package/src/utils/GsapAnim.tsx
CHANGED
|
@@ -26,13 +26,7 @@ interface Ease {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const getAnimByName = (
|
|
30
|
-
animate: string,
|
|
31
|
-
stageWidth?: number,
|
|
32
|
-
stageHeight?: number,
|
|
33
|
-
x?: number,
|
|
34
|
-
y?: number,
|
|
35
|
-
): Ease => {
|
|
29
|
+
export const getAnimByName = (animate: string): Ease => {
|
|
36
30
|
let ease: Ease = {};
|
|
37
31
|
switch (animate) {
|
|
38
32
|
case "NONE":
|