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.
Files changed (86) hide show
  1. package/dist/index.es.js +3586 -3583
  2. package/dist/index.umd.js +78 -78
  3. package/package.json +4 -1
  4. package/.storybook/main.ts +0 -31
  5. package/.storybook/preview.tsx +0 -26
  6. package/CHANGELOG.md +0 -100
  7. package/build-storybook.log +0 -94
  8. package/index.html +0 -13
  9. package/public/vite.svg +0 -1
  10. package/src/App.css +0 -42
  11. package/src/App.tsx +0 -29
  12. package/src/assets/font/OpenSans-Light-webfont.eot +0 -0
  13. package/src/assets/font/OpenSans-Light-webfont.svg +0 -252
  14. package/src/assets/font/OpenSans-Light-webfont.ttf +0 -0
  15. package/src/assets/font/OpenSans-Light-webfont.woff +0 -0
  16. package/src/assets/font/OpenSans-Regular-webfont.eot +0 -0
  17. package/src/assets/font/OpenSans-Regular-webfont.svg +0 -252
  18. package/src/assets/font/OpenSans-Regular-webfont.ttf +0 -0
  19. package/src/assets/font/OpenSans-Regular-webfont.woff +0 -0
  20. package/src/assets/icon/percolate.eot +0 -0
  21. package/src/assets/icon/percolate.svg +0 -139
  22. package/src/assets/icon/percolate.ttf +0 -0
  23. package/src/assets/icon/percolate.woff +0 -0
  24. package/src/assets/react.svg +0 -1
  25. package/src/components/PixiAnimatedSprite/PixiAnimatedSprite.tsx +0 -51
  26. package/src/components/PixiAnimatedSprite/index.ts +0 -2
  27. package/src/components/PixiAudioSprite/PixiAudioSprite.stories.tsx +0 -61
  28. package/src/components/PixiAudioSprite/PixiAudioSprite.tsx +0 -202
  29. package/src/components/PixiAudioSprite/index.ts +0 -1
  30. package/src/components/PixiGifSprite/PixiGifSprite.stories.tsx +0 -172
  31. package/src/components/PixiGifSprite/PixiGifSprite.tsx +0 -420
  32. package/src/components/PixiGifSprite/index.ts +0 -2
  33. package/src/components/PixiImageSprite/PixiImageSprite.stories.tsx +0 -220
  34. package/src/components/PixiImageSprite/PixiImageSprite.tsx +0 -60
  35. package/src/components/PixiImageSprite/index.ts +0 -1
  36. package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +0 -174
  37. package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +0 -158
  38. package/src/components/PixiSVGSprite/index.ts +0 -1
  39. package/src/components/PixiTextSprite/PixiTextSprite.stories.tsx +0 -228
  40. package/src/components/PixiTextSprite/PixiTextSprite.tsx +0 -361
  41. package/src/components/PixiTextSprite/index.ts +0 -1
  42. package/src/components/PixiVideoSprite/PixiVideoSprite.stories.tsx +0 -186
  43. package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +0 -595
  44. package/src/components/PixiVideoSprite/PixiVideoSpriteBackup.txt +0 -755
  45. package/src/components/PixiVideoSprite/index.ts +0 -1
  46. package/src/components/index.ts +0 -7
  47. package/src/declare.module.ts +0 -5
  48. package/src/hocs/AbstractContainer.tsx +0 -199
  49. package/src/hocs/WithFilterContainer.tsx +0 -159
  50. package/src/index.css +0 -457
  51. package/src/index.ts +0 -3
  52. package/src/main.tsx +0 -11
  53. package/src/providers/GsapPixieContextProvider.tsx +0 -245
  54. package/src/providers/index.ts +0 -1
  55. package/src/reacthub-react-bindings.d.ts +0 -27
  56. package/src/stories/Installation.mdx +0 -40
  57. package/src/stories/Introduction.mdx +0 -140
  58. package/src/stories/assets/code-brackets.svg +0 -1
  59. package/src/stories/assets/colors.svg +0 -1
  60. package/src/stories/assets/comments.svg +0 -1
  61. package/src/stories/assets/direction.svg +0 -1
  62. package/src/stories/assets/flow.svg +0 -1
  63. package/src/stories/assets/plugin.svg +0 -1
  64. package/src/stories/assets/repo.svg +0 -1
  65. package/src/stories/assets/stackalt.svg +0 -1
  66. package/src/types/Animations.tsx +0 -41
  67. package/src/types/BaseProps.tsx +0 -56
  68. package/src/types/BlendModes.tsx +0 -19
  69. package/src/types/Effects.tsx +0 -11
  70. package/src/types/transformation.tsx +0 -13
  71. package/src/utils/AppStateProvider.tsx +0 -59
  72. package/src/utils/AppStateStage.tsx +0 -15
  73. package/src/utils/AppWrapper.tsx +0 -47
  74. package/src/utils/ContextBridge.tsx +0 -25
  75. package/src/utils/GsapAnim.tsx +0 -107
  76. package/src/utils/InteractionManager.tsx +0 -36
  77. package/src/utils/PixiStage.tsx +0 -29
  78. package/src/utils/PixiTransformer.tsx +0 -165
  79. package/src/utils/VideoSeekBar.tsx +0 -122
  80. package/src/utils/useDebounce.tsx +0 -15
  81. package/src/utils/useDeepEffect.tsx +0 -23
  82. package/src/vite-env.d.ts +0 -1
  83. package/tsconfig.json +0 -37
  84. package/tsconfig.node.json +0 -10
  85. package/vite.config.ts +0 -39
  86. package/vitest.config.ts +0 -11
@@ -1 +0,0 @@
1
- export { default as PixiVideoSprite } from "./PixiVideoSprite";
@@ -1,7 +0,0 @@
1
- export * from "./PixiImageSprite";
2
- export * from "./PixiSVGSprite";
3
- export * from "./PixiAudioSprite";
4
- export * from "./PixiGifSprite";
5
- export * from "./PixiTextSprite";
6
- export * from "./PixiVideoSprite";
7
- export * from "./PixiAnimatedSprite";
@@ -1,5 +0,0 @@
1
- // declare module "@pixi/react" {
2
- // interface Container {
3
- // children?: React.ReactNode;
4
- // }
5
- // }
@@ -1,199 +0,0 @@
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;
@@ -1,159 +0,0 @@
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;