reacthub-pixitweenjs 0.2.10 → 0.2.12
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/dist/index.es.js +3586 -3583
- package/dist/index.umd.js +78 -78
- package/package.json +4 -1
- package/.storybook/main.ts +0 -31
- package/.storybook/preview.tsx +0 -26
- package/CHANGELOG.md +0 -100
- package/build-storybook.log +0 -94
- package/index.html +0 -13
- package/public/vite.svg +0 -1
- package/src/App.css +0 -42
- package/src/App.tsx +0 -29
- package/src/assets/font/OpenSans-Light-webfont.eot +0 -0
- package/src/assets/font/OpenSans-Light-webfont.svg +0 -252
- package/src/assets/font/OpenSans-Light-webfont.ttf +0 -0
- package/src/assets/font/OpenSans-Light-webfont.woff +0 -0
- package/src/assets/font/OpenSans-Regular-webfont.eot +0 -0
- package/src/assets/font/OpenSans-Regular-webfont.svg +0 -252
- package/src/assets/font/OpenSans-Regular-webfont.ttf +0 -0
- package/src/assets/font/OpenSans-Regular-webfont.woff +0 -0
- package/src/assets/icon/percolate.eot +0 -0
- package/src/assets/icon/percolate.svg +0 -139
- package/src/assets/icon/percolate.ttf +0 -0
- package/src/assets/icon/percolate.woff +0 -0
- package/src/assets/react.svg +0 -1
- package/src/components/PixiAnimatedSprite/PixiAnimatedSprite.tsx +0 -51
- package/src/components/PixiAnimatedSprite/index.ts +0 -2
- package/src/components/PixiAudioSprite/PixiAudioSprite.stories.tsx +0 -61
- package/src/components/PixiAudioSprite/PixiAudioSprite.tsx +0 -202
- package/src/components/PixiAudioSprite/index.ts +0 -1
- package/src/components/PixiGifSprite/PixiGifSprite.stories.tsx +0 -172
- package/src/components/PixiGifSprite/PixiGifSprite.tsx +0 -420
- package/src/components/PixiGifSprite/index.ts +0 -2
- package/src/components/PixiImageSprite/PixiImageSprite.stories.tsx +0 -220
- package/src/components/PixiImageSprite/PixiImageSprite.tsx +0 -60
- package/src/components/PixiImageSprite/index.ts +0 -1
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +0 -174
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +0 -158
- package/src/components/PixiSVGSprite/index.ts +0 -1
- package/src/components/PixiTextSprite/PixiTextSprite.stories.tsx +0 -228
- package/src/components/PixiTextSprite/PixiTextSprite.tsx +0 -361
- package/src/components/PixiTextSprite/index.ts +0 -1
- package/src/components/PixiVideoSprite/PixiVideoSprite.stories.tsx +0 -186
- package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +0 -595
- package/src/components/PixiVideoSprite/PixiVideoSpriteBackup.txt +0 -755
- package/src/components/PixiVideoSprite/index.ts +0 -1
- package/src/components/index.ts +0 -7
- package/src/declare.module.ts +0 -5
- package/src/hocs/AbstractContainer.tsx +0 -199
- package/src/hocs/WithFilterContainer.tsx +0 -159
- package/src/index.css +0 -457
- package/src/index.ts +0 -3
- package/src/main.tsx +0 -11
- package/src/providers/GsapPixieContextProvider.tsx +0 -245
- package/src/providers/index.ts +0 -1
- package/src/reacthub-react-bindings.d.ts +0 -27
- package/src/stories/Installation.mdx +0 -40
- package/src/stories/Introduction.mdx +0 -140
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/types/Animations.tsx +0 -41
- package/src/types/BaseProps.tsx +0 -56
- package/src/types/BlendModes.tsx +0 -19
- package/src/types/Effects.tsx +0 -11
- package/src/types/transformation.tsx +0 -13
- package/src/utils/AppStateProvider.tsx +0 -59
- package/src/utils/AppStateStage.tsx +0 -15
- package/src/utils/AppWrapper.tsx +0 -47
- package/src/utils/ContextBridge.tsx +0 -25
- package/src/utils/GsapAnim.tsx +0 -107
- package/src/utils/InteractionManager.tsx +0 -36
- package/src/utils/PixiStage.tsx +0 -29
- package/src/utils/PixiTransformer.tsx +0 -165
- package/src/utils/VideoSeekBar.tsx +0 -122
- package/src/utils/useDebounce.tsx +0 -15
- package/src/utils/useDeepEffect.tsx +0 -23
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -37
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -39
- package/vitest.config.ts +0 -11
package/src/utils/GsapAnim.tsx
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
interface Ease {
|
|
2
|
-
from?: {
|
|
3
|
-
duration: number;
|
|
4
|
-
ease: string;
|
|
5
|
-
y?: number;
|
|
6
|
-
x?: number;
|
|
7
|
-
};
|
|
8
|
-
fromTo?: {
|
|
9
|
-
from: {
|
|
10
|
-
y?: number;
|
|
11
|
-
x?: number;
|
|
12
|
-
alpha?: number;
|
|
13
|
-
};
|
|
14
|
-
to: {
|
|
15
|
-
ease: string;
|
|
16
|
-
y?: number;
|
|
17
|
-
x?: number;
|
|
18
|
-
alpha?: number;
|
|
19
|
-
duration: number;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
to?: {
|
|
23
|
-
ease: string;
|
|
24
|
-
alpha: number;
|
|
25
|
-
duration: number;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const getAnimByName = (animate: string): Ease => {
|
|
30
|
-
let ease: Ease = {};
|
|
31
|
-
switch (animate) {
|
|
32
|
-
case "NONE":
|
|
33
|
-
case "none":
|
|
34
|
-
break;
|
|
35
|
-
case "BOUNCE_IN":
|
|
36
|
-
ease.from = {
|
|
37
|
-
duration: 2,
|
|
38
|
-
ease: "bounce.out",
|
|
39
|
-
y: -1500,
|
|
40
|
-
};
|
|
41
|
-
break;
|
|
42
|
-
case "BOUNCE_IN_DOWN":
|
|
43
|
-
ease.from = { ease: "bounce.out", y: -1500, duration: 2 };
|
|
44
|
-
break;
|
|
45
|
-
case "BOUNCE_IN_LEFT":
|
|
46
|
-
ease.from = { ease: "bounce.out", x: -1500, duration: 2 };
|
|
47
|
-
break;
|
|
48
|
-
case "BOUNCE_IN_RIGHT":
|
|
49
|
-
ease.from = { ease: "bounce.out", x: 1500, duration: 2 };
|
|
50
|
-
break;
|
|
51
|
-
case "BOUNCE_IN_UP":
|
|
52
|
-
ease.from = { ease: "bounce.out", y: 1500, duration: 2 };
|
|
53
|
-
break;
|
|
54
|
-
case "BOUNCE_OUT":
|
|
55
|
-
ease.from = { ease: "bounce.in", y: 2, duration: 2 };
|
|
56
|
-
break;
|
|
57
|
-
case "BOUNCE_OUT_DOWN":
|
|
58
|
-
break;
|
|
59
|
-
case "BOUNCE_OUT_LEFT":
|
|
60
|
-
break;
|
|
61
|
-
case "BOUNCE_OUT_RIGHT":
|
|
62
|
-
break;
|
|
63
|
-
case "BOUNCE_OUT_UP":
|
|
64
|
-
break;
|
|
65
|
-
case "FADE_IN":
|
|
66
|
-
ease.to = { ease: "power4.in", alpha: 1, duration: 0.5 };
|
|
67
|
-
break;
|
|
68
|
-
case "FADE_IN_DOWN":
|
|
69
|
-
ease.fromTo = {
|
|
70
|
-
from: { y: -1000, alpha: 0 },
|
|
71
|
-
to: { ease: "power4.in", y: 0, alpha: 1, duration: 1 },
|
|
72
|
-
};
|
|
73
|
-
break;
|
|
74
|
-
case "FADE_IN_LEFT":
|
|
75
|
-
ease.fromTo = {
|
|
76
|
-
from: { x: -1000, alpha: 0 },
|
|
77
|
-
to: { ease: "power4.in", x: 0, alpha: 1, duration: 1 },
|
|
78
|
-
};
|
|
79
|
-
break;
|
|
80
|
-
case "FADE_IN_RIGHT":
|
|
81
|
-
ease.fromTo = {
|
|
82
|
-
from: { x: 2000, alpha: 0 },
|
|
83
|
-
to: { ease: "power4.in", x: 0, alpha: 1, duration: 1 },
|
|
84
|
-
};
|
|
85
|
-
break;
|
|
86
|
-
case "FADE_IN_UP":
|
|
87
|
-
ease.fromTo = {
|
|
88
|
-
from: { y: 2000, alpha: 0 },
|
|
89
|
-
to: { ease: "power4.in", y: 0, alpha: 1, duration: 1 },
|
|
90
|
-
};
|
|
91
|
-
break;
|
|
92
|
-
case "FADE_OUT":
|
|
93
|
-
break;
|
|
94
|
-
case "FADE_OUT_DOWN":
|
|
95
|
-
break;
|
|
96
|
-
case "FADE_OUT_LEFT":
|
|
97
|
-
break;
|
|
98
|
-
case "FADE_OUT_RIGHT":
|
|
99
|
-
break;
|
|
100
|
-
case "FADE_OUT_UP":
|
|
101
|
-
break;
|
|
102
|
-
default:
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return ease;
|
|
107
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useApp } from "@pixi/react";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
|
|
4
|
-
type PixiInteractionManagerProps = {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
options?: {
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const interactionManagerSettings = { moveWhenInside: true };
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Initialize Pixi Interaction Manager
|
|
15
|
-
* @param param0
|
|
16
|
-
* @returns
|
|
17
|
-
* @see https://pixijs.download/dev/docs/PIXI.InteractionManager.html
|
|
18
|
-
* @see https://pixijs.download/dev/docs/PIXI.InteractionManager.html#moveWhenInside
|
|
19
|
-
* @see https://pixijs.download/dev/docs/PIXI.InteractionManager.html#on
|
|
20
|
-
*
|
|
21
|
-
* */
|
|
22
|
-
const InteractionManager = ({
|
|
23
|
-
children,
|
|
24
|
-
options = interactionManagerSettings,
|
|
25
|
-
}: PixiInteractionManagerProps) => {
|
|
26
|
-
const app = useApp();
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
Object.keys(options).forEach((key) => {
|
|
30
|
-
app.renderer.plugins.interaction[key] = options[key];
|
|
31
|
-
});
|
|
32
|
-
}, [options]);
|
|
33
|
-
|
|
34
|
-
return children;
|
|
35
|
-
};
|
|
36
|
-
export default InteractionManager;
|
package/src/utils/PixiStage.tsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import ContextBridge from "./ContextBridge";
|
|
3
|
-
import { Stage as PixiStage } from "@pixi/react";
|
|
4
|
-
import { GsapPixieContext } from "../providers/GsapPixieContextProvider";
|
|
5
|
-
|
|
6
|
-
interface StageProps {
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
options: any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const Stage: React.FC<StageProps> = ({ children, ...props }) => {
|
|
14
|
-
return (
|
|
15
|
-
<ContextBridge
|
|
16
|
-
Context={GsapPixieContext}
|
|
17
|
-
render={(children: React.ReactNode | React.ReactElement) => (
|
|
18
|
-
<PixiStage {...props}>
|
|
19
|
-
{/* @ts-ignore */}
|
|
20
|
-
{children}
|
|
21
|
-
</PixiStage>
|
|
22
|
-
)}
|
|
23
|
-
>
|
|
24
|
-
{children}
|
|
25
|
-
</ContextBridge>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default Stage;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import * as PIXI from "pixi.js";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import { Transformer } from "reacthub-react-bindings";
|
|
5
|
-
|
|
6
|
-
type PixiTransformerProps = {
|
|
7
|
-
pixiTransformerRef: React.MutableRefObject<any>;
|
|
8
|
-
imageRef: React.MutableRefObject<any>;
|
|
9
|
-
isMounted: boolean;
|
|
10
|
-
transformCommit?: (data: any) => void;
|
|
11
|
-
transformChange?: (data: any) => void;
|
|
12
|
-
mouseoverEvent?: (flag: boolean) => void;
|
|
13
|
-
onDoubleClick?: (data: any) => void;
|
|
14
|
-
uniqueId?: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type PixiTransformerState = {
|
|
18
|
-
isDragging: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Initialize PixiTransformer to transform the image
|
|
23
|
-
* @param param0
|
|
24
|
-
* @returns
|
|
25
|
-
*/
|
|
26
|
-
const PixiTransformer = ({
|
|
27
|
-
pixiTransformerRef,
|
|
28
|
-
imageRef,
|
|
29
|
-
isMounted,
|
|
30
|
-
transformCommit,
|
|
31
|
-
transformChange,
|
|
32
|
-
mouseoverEvent,
|
|
33
|
-
onDoubleClick,
|
|
34
|
-
uniqueId = "",
|
|
35
|
-
}: PixiTransformerProps) => {
|
|
36
|
-
// states
|
|
37
|
-
const colorYellow = PIXI.utils.string2hex("#F3C409");
|
|
38
|
-
const anchorFill = PIXI.utils.string2hex("#F3C409");
|
|
39
|
-
const transformerState = React.useRef<PixiTransformerState>({
|
|
40
|
-
isDragging: false,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const handleOnMouseOver = React.useCallback(() => {
|
|
44
|
-
if (mouseoverEvent && !transformerState.current.isDragging) {
|
|
45
|
-
mouseoverEvent(true);
|
|
46
|
-
}
|
|
47
|
-
}, [mouseoverEvent]);
|
|
48
|
-
|
|
49
|
-
const handleOnMouseOut = React.useCallback(() => {
|
|
50
|
-
if (mouseoverEvent && !transformerState.current.isDragging) {
|
|
51
|
-
mouseoverEvent(false);
|
|
52
|
-
}
|
|
53
|
-
}, [mouseoverEvent]);
|
|
54
|
-
|
|
55
|
-
const handleOnMouseDown = React.useCallback(() => {
|
|
56
|
-
// update transfomer state to is draggin.
|
|
57
|
-
transformerState.current.isDragging = true;
|
|
58
|
-
}, []);
|
|
59
|
-
|
|
60
|
-
const handleOnMouseUp = React.useCallback(() => {
|
|
61
|
-
// update transfomer state to is not dragging.
|
|
62
|
-
transformerState.current.isDragging = false;
|
|
63
|
-
}, []);
|
|
64
|
-
|
|
65
|
-
const handleOnMouseUpOutside = React.useCallback(() => {
|
|
66
|
-
// update transfomer state to is not dragging.
|
|
67
|
-
transformerState.current.isDragging = false;
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
const handleOnDoubleClick = React.useCallback(() => {
|
|
71
|
-
console.log("dobule click in pixi transformer");
|
|
72
|
-
if (onDoubleClick) onDoubleClick({ uniqueId });
|
|
73
|
-
}, [onDoubleClick]);
|
|
74
|
-
|
|
75
|
-
// add handler for transform change
|
|
76
|
-
const handleOnTransformChange = React.useCallback(
|
|
77
|
-
(e: any) => {
|
|
78
|
-
// update transfomer state to is draggin.
|
|
79
|
-
transformerState.current.isDragging = true;
|
|
80
|
-
if (transformChange) transformChange(e);
|
|
81
|
-
},
|
|
82
|
-
[transformChange]
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const handleOnTransformCommit = React.useCallback(() => {
|
|
86
|
-
if (imageRef.current === null) return;
|
|
87
|
-
const x = imageRef.current.x;
|
|
88
|
-
const y = imageRef.current.y;
|
|
89
|
-
const width = imageRef.current.width;
|
|
90
|
-
const height = imageRef.current.height;
|
|
91
|
-
const rotate = imageRef.current.rotation;
|
|
92
|
-
const scale: [number, number] = [
|
|
93
|
-
imageRef.current.scale.x,
|
|
94
|
-
imageRef.current.scale.y,
|
|
95
|
-
];
|
|
96
|
-
if (transformCommit) {
|
|
97
|
-
transformCommit({
|
|
98
|
-
uniqueId,
|
|
99
|
-
transformation: {
|
|
100
|
-
x: Math.round(x),
|
|
101
|
-
y: Math.round(y),
|
|
102
|
-
width: Math.round(Math.max(5, width)),
|
|
103
|
-
height: Math.round(Math.max(5, height)),
|
|
104
|
-
rotate: Math.round(rotate),
|
|
105
|
-
scale: scale,
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
// update transformer state to is not dragging.
|
|
110
|
-
transformerState.current.isDragging = false;
|
|
111
|
-
}, [transformCommit]);
|
|
112
|
-
|
|
113
|
-
React.useEffect(() => {
|
|
114
|
-
if (pixiTransformerRef.current) {
|
|
115
|
-
pixiTransformerRef.current.on("mouseover", handleOnMouseOver);
|
|
116
|
-
pixiTransformerRef.current.on("mouseout", handleOnMouseOut);
|
|
117
|
-
pixiTransformerRef.current.on("mousedown", handleOnMouseDown);
|
|
118
|
-
pixiTransformerRef.current.on("mouseup", handleOnMouseUp);
|
|
119
|
-
pixiTransformerRef.current.on("mouseupoutside", handleOnMouseUpOutside);
|
|
120
|
-
/// pixiTransformerRef.current.on("dblclick", handleOnDoubleClick);
|
|
121
|
-
pixiTransformerRef.current.addListener("dblclick", handleOnDoubleClick);
|
|
122
|
-
}
|
|
123
|
-
return () => {
|
|
124
|
-
if (pixiTransformerRef.current) {
|
|
125
|
-
pixiTransformerRef.current.off("mouseover", handleOnMouseOver);
|
|
126
|
-
pixiTransformerRef.current.off("mouseout", handleOnMouseOut);
|
|
127
|
-
pixiTransformerRef.current.off("mousedown", handleOnMouseDown);
|
|
128
|
-
pixiTransformerRef.current.off("mouseup", handleOnMouseUp);
|
|
129
|
-
pixiTransformerRef.current.off(
|
|
130
|
-
"mouseupoutside",
|
|
131
|
-
handleOnMouseUpOutside
|
|
132
|
-
);
|
|
133
|
-
//// pixiTransformerRef.current.off("dblclick", handleOnDoubleClick);
|
|
134
|
-
pixiTransformerRef.current.removeListener(
|
|
135
|
-
"dblclick",
|
|
136
|
-
handleOnDoubleClick
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
}, []);
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<Transformer
|
|
144
|
-
ref={pixiTransformerRef}
|
|
145
|
-
group={isMounted ? [imageRef.current] : []}
|
|
146
|
-
rotateEnabled={true}
|
|
147
|
-
boxRotationEnabled={true}
|
|
148
|
-
centeredScaling={true}
|
|
149
|
-
boxScalingEnabled={true}
|
|
150
|
-
wireframeStyle={{ thickness: 1, color: anchorFill }}
|
|
151
|
-
lockAspectRatio={true}
|
|
152
|
-
scaleEnabled={true}
|
|
153
|
-
handleStyle={{
|
|
154
|
-
// color: colorYellow,
|
|
155
|
-
outlineColor: colorYellow,
|
|
156
|
-
shape: "circle",
|
|
157
|
-
radius: 9,
|
|
158
|
-
}}
|
|
159
|
-
transformchange={handleOnTransformChange}
|
|
160
|
-
transformcommit={handleOnTransformCommit}
|
|
161
|
-
/>
|
|
162
|
-
);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export default PixiTransformer;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
Slider,
|
|
4
|
-
SliderTrack,
|
|
5
|
-
SliderFilledTrack,
|
|
6
|
-
SliderThumb,
|
|
7
|
-
Flex,
|
|
8
|
-
Text,
|
|
9
|
-
Box,
|
|
10
|
-
Button,
|
|
11
|
-
} from "@chakra-ui/react";
|
|
12
|
-
import {
|
|
13
|
-
GsapPixieContext,
|
|
14
|
-
Events,
|
|
15
|
-
} from "../providers/GsapPixieContextProvider";
|
|
16
|
-
import { emitCustomEvent } from "react-custom-events";
|
|
17
|
-
|
|
18
|
-
import { gsap } from "gsap";
|
|
19
|
-
import { Draggable } from "gsap/Draggable";
|
|
20
|
-
|
|
21
|
-
gsap.registerPlugin(Draggable);
|
|
22
|
-
|
|
23
|
-
export const VideoSeekBar: React.FC = () => {
|
|
24
|
-
const rafRef = React.useRef<number>();
|
|
25
|
-
const sliderThumbRef = React.useRef<HTMLDivElement>(null);
|
|
26
|
-
const {
|
|
27
|
-
tl: timeline,
|
|
28
|
-
playerTimeRef,
|
|
29
|
-
handlePlay,
|
|
30
|
-
handlePause,
|
|
31
|
-
handleSeekTest,
|
|
32
|
-
handleRestart,
|
|
33
|
-
totalDuration: duration,
|
|
34
|
-
} = React.useContext(GsapPixieContext);
|
|
35
|
-
|
|
36
|
-
/// state
|
|
37
|
-
const [time, setTime] = React.useState<number>(0);
|
|
38
|
-
const totalVideoSeconds = 20;
|
|
39
|
-
|
|
40
|
-
const animate = () => {
|
|
41
|
-
/// console.log("totalDuration", timeline.current.totalDuration());
|
|
42
|
-
if (playerTimeRef && playerTimeRef.current) {
|
|
43
|
-
setTime(playerTimeRef.current);
|
|
44
|
-
}
|
|
45
|
-
rafRef.current = requestAnimationFrame(animate);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
React.useEffect(() => {
|
|
49
|
-
rafRef.current = requestAnimationFrame(animate);
|
|
50
|
-
return () => cancelAnimationFrame(rafRef.current!);
|
|
51
|
-
}, []); // Make sure the effect runs only once
|
|
52
|
-
|
|
53
|
-
const handleOnSliderChange = (value: number) => {
|
|
54
|
-
console.log("onslider change", value);
|
|
55
|
-
const nTotSeconds =
|
|
56
|
-
totalVideoSeconds && totalVideoSeconds > 0 ? totalVideoSeconds : 1;
|
|
57
|
-
const progress = value / nTotSeconds;
|
|
58
|
-
console.log("progressbar", value, progress);
|
|
59
|
-
|
|
60
|
-
playerTimeRef.current = value;
|
|
61
|
-
// handleSeek(value);
|
|
62
|
-
// // @ts-ignore
|
|
63
|
-
timeline && timeline.current.progress(progress);
|
|
64
|
-
// timeline && timeline.current.pause();
|
|
65
|
-
// gsap.set(sliderProgressRef.current!, {
|
|
66
|
-
// scaleX: progress,
|
|
67
|
-
// });
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/** on slider start
|
|
71
|
-
* 1. pause the timeline
|
|
72
|
-
* 2. trigger custom event isDraggingStart
|
|
73
|
-
*/
|
|
74
|
-
const handleOnSliderChangeStart = () => {
|
|
75
|
-
// trigger custom event and pause the timeline
|
|
76
|
-
emitCustomEvent(Events.DRAGGING_START);
|
|
77
|
-
timeline && timeline.current.pause();
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const handleOnSliderChangeEnd = () => {
|
|
81
|
-
// trigger custom event and pause the timeline
|
|
82
|
-
emitCustomEvent(Events.DRAGGING_END);
|
|
83
|
-
timeline && timeline.current.pause();
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/** Create Draggable for the Gsap Player */
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<Flex flexDir={"column"}>
|
|
90
|
-
<Box>
|
|
91
|
-
<Button onClick={handleRestart}>Play</Button>
|
|
92
|
-
<Button onClick={handlePause}>Pause</Button>
|
|
93
|
-
<Button onClick={handlePlay}>Resume</Button>
|
|
94
|
-
<Button onClick={handleSeekTest}>Seek (4:00)</Button>
|
|
95
|
-
</Box>
|
|
96
|
-
<Flex px={1} mt={2}>
|
|
97
|
-
<Slider
|
|
98
|
-
aria-label="slider-ex-1"
|
|
99
|
-
data-testid="sliderthumb"
|
|
100
|
-
value={playerTimeRef.current || 0}
|
|
101
|
-
min={0}
|
|
102
|
-
max={10}
|
|
103
|
-
step={0.1}
|
|
104
|
-
onChange={handleOnSliderChange}
|
|
105
|
-
onChangeStart={handleOnSliderChangeStart}
|
|
106
|
-
onChangeEnd={handleOnSliderChangeEnd}
|
|
107
|
-
>
|
|
108
|
-
<SliderTrack>
|
|
109
|
-
<SliderFilledTrack />
|
|
110
|
-
</SliderTrack>
|
|
111
|
-
<SliderThumb data-testid="sliderthumb" ref={sliderThumbRef} />
|
|
112
|
-
</Slider>
|
|
113
|
-
</Flex>
|
|
114
|
-
<Flex flexDir={"row"}>
|
|
115
|
-
<Text>
|
|
116
|
-
Gsap-CurrentTime: {Math.round((time + Number.EPSILON) * 100) / 100} /{" "}
|
|
117
|
-
{duration}
|
|
118
|
-
</Text>
|
|
119
|
-
</Flex>
|
|
120
|
-
</Flex>
|
|
121
|
-
);
|
|
122
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export function useDebounce<T>(value: T, delay?: number): T {
|
|
4
|
-
const [debouncedValue, setDebouncedValue] = useState<T>(value);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const timer = setTimeout(() => setDebouncedValue(value), delay || 500);
|
|
8
|
-
|
|
9
|
-
return () => {
|
|
10
|
-
clearTimeout(timer);
|
|
11
|
-
};
|
|
12
|
-
}, [value, delay]);
|
|
13
|
-
|
|
14
|
-
return debouncedValue;
|
|
15
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import isEqual from "react-fast-compare";
|
|
4
|
-
|
|
5
|
-
type EffectFunc = () => void;
|
|
6
|
-
type Deps = ReadonlyArray<unknown>;
|
|
7
|
-
|
|
8
|
-
const useDeepEffect = (effectFunc: EffectFunc, deps: Deps) => {
|
|
9
|
-
const isFirst = useRef(true);
|
|
10
|
-
const prevDeps = useRef(deps);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const isSame = prevDeps.current.every((obj, index) =>
|
|
13
|
-
isEqual(obj, deps[index]),
|
|
14
|
-
);
|
|
15
|
-
if (isFirst.current || !isSame) {
|
|
16
|
-
effectFunc();
|
|
17
|
-
}
|
|
18
|
-
isFirst.current = false;
|
|
19
|
-
prevDeps.current = deps;
|
|
20
|
-
}, deps);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default useDeepEffect;
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
5
|
-
"plugins": [
|
|
6
|
-
{
|
|
7
|
-
"name": "typescript-plugin-css-modules",
|
|
8
|
-
"options": {
|
|
9
|
-
"postcssOptions": {
|
|
10
|
-
"useConfig": true
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"module": "ESNext",
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
/* Bundler mode */
|
|
18
|
-
"moduleResolution": "node",
|
|
19
|
-
"allowImportingTsExtensions": false,
|
|
20
|
-
"resolveJsonModule": true,
|
|
21
|
-
"isolatedModules": true,
|
|
22
|
-
"noEmit": true,
|
|
23
|
-
"jsx": "react-jsx",
|
|
24
|
-
"types": ["vitest/globals"],
|
|
25
|
-
/* Linting */
|
|
26
|
-
"strict": true,
|
|
27
|
-
"noUnusedLocals": true,
|
|
28
|
-
"noUnusedParameters": true,
|
|
29
|
-
"noFallthroughCasesInSwitch": true
|
|
30
|
-
},
|
|
31
|
-
"include": ["src"],
|
|
32
|
-
"references": [
|
|
33
|
-
{
|
|
34
|
-
"path": "./tsconfig.node.json"
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
}
|
package/tsconfig.node.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
// import react from "@vitejs/plugin-react";
|
|
3
|
-
import react from "@vitejs/plugin-react-swc";
|
|
4
|
-
import EnvironmentPlugin from "vite-plugin-environment";
|
|
5
|
-
|
|
6
|
-
// https://vitejs.dev/config/
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
plugins: [react(), EnvironmentPlugin("all")],
|
|
9
|
-
build: {
|
|
10
|
-
lib: {
|
|
11
|
-
entry: "src/index.ts",
|
|
12
|
-
name: "reacthub-pixitweenjs",
|
|
13
|
-
fileName: (format) => `index.${format}.js`,
|
|
14
|
-
},
|
|
15
|
-
rollupOptions: {
|
|
16
|
-
external: [
|
|
17
|
-
"react",
|
|
18
|
-
"react-dom",
|
|
19
|
-
"pixi.js",
|
|
20
|
-
"gsap",
|
|
21
|
-
// "pixi.js-legacy",
|
|
22
|
-
// "pixi-sound",
|
|
23
|
-
// "pixi-viewport",
|
|
24
|
-
// "pixi-viewport-extensions",
|
|
25
|
-
// "@pixi/core",
|
|
26
|
-
// "@pixi/display",
|
|
27
|
-
// "@pixi/app",
|
|
28
|
-
],
|
|
29
|
-
output: {
|
|
30
|
-
globals: {
|
|
31
|
-
react: "React",
|
|
32
|
-
"react-dom": "ReactDOM",
|
|
33
|
-
"pixi.js": "PIXI",
|
|
34
|
-
gsap: "gsap",
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
});
|