@plasmicpkgs/react-scroll-parallax 0.0.97 → 0.0.98
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/react-scroll-parallax.cjs.development.js +6 -23
- package/dist/react-scroll-parallax.cjs.development.js.map +1 -1
- package/dist/react-scroll-parallax.cjs.production.min.js +1 -1
- package/dist/react-scroll-parallax.cjs.production.min.js.map +1 -1
- package/dist/react-scroll-parallax.esm.js +6 -23
- package/dist/react-scroll-parallax.esm.js.map +1 -1
- package/package.json +3 -3
|
@@ -13,52 +13,44 @@ var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGl
|
|
|
13
13
|
var ResizeObserver = _interopDefault(require('resize-observer-polyfill'));
|
|
14
14
|
|
|
15
15
|
function _extends() {
|
|
16
|
-
_extends = Object.assign
|
|
16
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
17
|
for (var i = 1; i < arguments.length; i++) {
|
|
18
18
|
var source = arguments[i];
|
|
19
|
-
|
|
20
19
|
for (var key in source) {
|
|
21
20
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
21
|
target[key] = source[key];
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
return target;
|
|
28
26
|
};
|
|
29
|
-
|
|
30
27
|
return _extends.apply(this, arguments);
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
34
30
|
if (source == null) return {};
|
|
35
31
|
var target = {};
|
|
36
32
|
var sourceKeys = Object.keys(source);
|
|
37
33
|
var key, i;
|
|
38
|
-
|
|
39
34
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
40
35
|
key = sourceKeys[i];
|
|
41
36
|
if (excluded.indexOf(key) >= 0) continue;
|
|
42
37
|
target[key] = source[key];
|
|
43
38
|
}
|
|
44
|
-
|
|
45
39
|
return target;
|
|
46
40
|
}
|
|
47
41
|
|
|
48
42
|
function ParallaxWrapper(_ref) {
|
|
49
43
|
var speed = _ref.speed,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
disabled = _ref.disabled,
|
|
45
|
+
previewInEditor = _ref.previewInEditor,
|
|
46
|
+
children = _ref.children,
|
|
47
|
+
className = _ref.className;
|
|
54
48
|
var inEditor = React.useContext(host.PlasmicCanvasContext);
|
|
55
49
|
var hasContext = React.useContext(reactScrollParallax.ParallaxContext) != null;
|
|
56
50
|
var isServer = typeof window === "undefined";
|
|
57
|
-
|
|
58
51
|
if (!hasContext && !isServer) {
|
|
59
52
|
throw new Error("Scroll Parallax can only be instantiated somewhere inside the Parallax Provider");
|
|
60
53
|
}
|
|
61
|
-
|
|
62
54
|
return React__default.createElement(reactScrollParallax.Parallax, {
|
|
63
55
|
disabled: disabled || inEditor && !previewInEditor,
|
|
64
56
|
speed: speed,
|
|
@@ -72,7 +64,6 @@ function ParallaxWrapper(_ref) {
|
|
|
72
64
|
* break it and it wouldn't be clear that the user should also add a
|
|
73
65
|
* `ParallaxProvider`).
|
|
74
66
|
*/
|
|
75
|
-
|
|
76
67
|
var deprecated_parallaxWrapperMeta = {
|
|
77
68
|
name: "hostless-scroll-parallax",
|
|
78
69
|
displayName: "Scroll Parallax",
|
|
@@ -117,7 +108,6 @@ function deprecated_registerParallaxWrapper(loader, customParallaxWrapperMeta) {
|
|
|
117
108
|
/**
|
|
118
109
|
* The new registration is only setting `isAttachment: true`.
|
|
119
110
|
*/
|
|
120
|
-
|
|
121
111
|
var parallaxWrapperMeta = /*#__PURE__*/_extends({}, deprecated_parallaxWrapperMeta, {
|
|
122
112
|
isAttachment: true
|
|
123
113
|
});
|
|
@@ -140,14 +130,12 @@ var _excluded = ["children"];
|
|
|
140
130
|
* document (which may be large), but we can probably optimize this in the
|
|
141
131
|
* future.
|
|
142
132
|
*/
|
|
143
|
-
|
|
144
133
|
function ParallaxCacheUpdate(_ref) {
|
|
145
134
|
var children = _ref.children;
|
|
146
135
|
var parallaxController = reactScrollParallax.useController();
|
|
147
136
|
var ref = React.useRef(null);
|
|
148
137
|
React.useEffect(function () {
|
|
149
138
|
var _ref$current;
|
|
150
|
-
|
|
151
139
|
if ((_ref$current = ref.current) != null && _ref$current.parentElement) {
|
|
152
140
|
var targetNode = ref.current.parentElement;
|
|
153
141
|
var observer = new ResizeObserver(function () {
|
|
@@ -160,7 +148,6 @@ function ParallaxCacheUpdate(_ref) {
|
|
|
160
148
|
observer.disconnect();
|
|
161
149
|
};
|
|
162
150
|
}
|
|
163
|
-
|
|
164
151
|
return function () {};
|
|
165
152
|
}, [ref.current]);
|
|
166
153
|
return React__default.createElement("div", {
|
|
@@ -170,17 +157,14 @@ function ParallaxCacheUpdate(_ref) {
|
|
|
170
157
|
ref: ref
|
|
171
158
|
}, children);
|
|
172
159
|
}
|
|
173
|
-
|
|
174
160
|
function ParallaxProviderWrapper(_ref2) {
|
|
175
161
|
var children = _ref2.children,
|
|
176
|
-
|
|
177
|
-
|
|
162
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
178
163
|
return React__default.createElement(reactScrollParallax.ParallaxProvider, Object.assign({}, props), React__default.createElement(ParallaxCacheUpdate, null, children));
|
|
179
164
|
}
|
|
180
165
|
/**
|
|
181
166
|
* @deprecated use `globalParallaxProviderMeta` instead.
|
|
182
167
|
*/
|
|
183
|
-
|
|
184
168
|
var parallaxProviderMeta = {
|
|
185
169
|
name: "hostless-parallax-provider",
|
|
186
170
|
displayName: "Parallax Provider",
|
|
@@ -214,7 +198,6 @@ var parallaxProviderMeta = {
|
|
|
214
198
|
/**
|
|
215
199
|
* @deprecated use `registerGlobalParallaxProvider` instead.
|
|
216
200
|
*/
|
|
217
|
-
|
|
218
201
|
function registerParallaxProvider(loader, customParallaxProviderMeta) {
|
|
219
202
|
if (loader) {
|
|
220
203
|
loader.registerComponent(ParallaxProviderWrapper, customParallaxProviderMeta != null ? customParallaxProviderMeta : parallaxProviderMeta);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-scroll-parallax.cjs.development.js","sources":["../src/ParallaxWrapper.tsx","../src/ParallaxProvider.tsx"],"sourcesContent":["import { PlasmicCanvasContext } from \"@plasmicapp/host\";\nimport registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React, { useContext } from \"react\";\nimport { Parallax, ParallaxContext } from \"react-scroll-parallax\";\n\nexport interface ParallaxWrapperProps {\n speed?: number;\n disabled?: boolean;\n previewInEditor?: boolean;\n children: React.ReactNode;\n className?: string;\n}\n\nexport default function ParallaxWrapper({\n speed,\n disabled,\n previewInEditor,\n children,\n className,\n}: ParallaxWrapperProps) {\n const inEditor = useContext(PlasmicCanvasContext);\n const hasContext = useContext(ParallaxContext) != null;\n const isServer = typeof window === \"undefined\";\n if (!hasContext && !isServer) {\n throw new Error(\n \"Scroll Parallax can only be instantiated somewhere inside the Parallax Provider\"\n );\n }\n return (\n <Parallax\n disabled={disabled || (inEditor && !previewInEditor)}\n speed={speed}\n className={className}\n >\n {children}\n </Parallax>\n );\n}\n\n/**\n * We're keeping the old registration without attachments to avoid confusion\n * due to the parallax custom behavior not working in old projects that didn't\n * make use of global contexts (so simply adding the custom behavior would\n * break it and it wouldn't be clear that the user should also add a\n * `ParallaxProvider`).\n */\nexport const deprecated_parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> =\n {\n name: \"hostless-scroll-parallax\",\n displayName: \"Scroll Parallax\",\n importName: \"ParallaxWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"img\",\n src: \"https://placekitten.com/300/200\",\n style: {\n maxWidth: \"100%\",\n },\n },\n },\n speed: {\n type: \"number\",\n description:\n \"How much to speed up or slow down this element while scrolling. Try -20 for slower, 20 for faster.\",\n defaultValue: 20,\n },\n disabled: {\n type: \"boolean\",\n description: \"Disables the parallax effect.\",\n },\n previewInEditor: {\n type: \"boolean\",\n description: \"Enable the parallax effect in the editor.\",\n },\n },\n defaultStyles: {\n maxWidth: \"100%\",\n },\n };\n\nexport function deprecated_registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n }\n}\n\n/**\n * The new registration is only setting `isAttachment: true`.\n */\nexport const parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> = {\n ...deprecated_parallaxWrapperMeta,\n isAttachment: true,\n};\n\nexport function registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport React, { useEffect, useRef } from \"react\";\nimport { ParallaxProvider, useController } from \"react-scroll-parallax\";\nimport { ParallaxProviderProps } from \"react-scroll-parallax/dist/components/ParallaxProvider/types\";\nimport ResizeObserver from \"resize-observer-polyfill\";\n\n/**\n * This is required to ensure the parallax scrolling works correctly, since if\n * (for instance) images load after the parallax wrapper has calculated the\n * dimensions of the space, it will result in incorrect parallax scrolling\n * amounts.\n *\n * This is not great since we need to mutation-observe the whole section of the\n * document (which may be large), but we can probably optimize this in the\n * future.\n */\nfunction ParallaxCacheUpdate({ children }: React.PropsWithChildren<{}>) {\n const parallaxController = useController();\n const ref = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (ref.current?.parentElement) {\n const targetNode = ref.current.parentElement;\n const observer = new ResizeObserver(() => {\n if (parallaxController) {\n parallaxController.update();\n }\n });\n observer.observe(targetNode);\n return () => {\n observer.disconnect();\n };\n }\n return () => {};\n }, [ref.current]);\n\n return (\n <div style={{ display: \"contents\" }} ref={ref}>\n {children}\n </div>\n );\n}\n\nexport function ParallaxProviderWrapper({\n children,\n ...props\n}: React.PropsWithChildren<ParallaxProviderProps>) {\n return (\n <ParallaxProvider {...props}>\n <ParallaxCacheUpdate>{children}</ParallaxCacheUpdate>\n </ParallaxProvider>\n );\n}\n\n/**\n * @deprecated use `globalParallaxProviderMeta` instead.\n */\nexport const parallaxProviderMeta: ComponentMeta<ParallaxProviderProps> = {\n name: \"hostless-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"text\",\n value:\n \"Wrap any element in a Scroll Parallax component. Ensure they're all inside this Parallax Provider. Example:\",\n styles: {\n marginBottom: \"20px\",\n },\n },\n {\n type: \"component\",\n name: \"hostless-scroll-parallax\",\n },\n ],\n },\n },\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n};\n\n/**\n * @deprecated use `registerGlobalParallaxProvider` instead.\n */\nexport function registerParallaxProvider(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxProviderMeta?: ComponentMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n } else {\n registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n }\n}\n\nexport const globalParallaxProviderMeta: GlobalContextMeta<ParallaxProviderProps> =\n {\n name: \"global-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n };\n\nexport function registerGlobalParallaxProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customParallaxProviderMeta?: GlobalContextMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n } else {\n registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n }\n}\n"],"names":["ParallaxWrapper","speed","disabled","previewInEditor","children","className","inEditor","useContext","PlasmicCanvasContext","hasContext","ParallaxContext","isServer","window","Error","React","Parallax","deprecated_parallaxWrapperMeta","name","displayName","importName","importPath","props","type","defaultValue","src","style","maxWidth","description","defaultStyles","deprecated_registerParallaxWrapper","loader","customParallaxWrapperMeta","registerComponent","parallaxWrapperMeta","isAttachment","registerParallaxWrapper","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","display","ParallaxProviderWrapper","ParallaxProvider","parallaxProviderMeta","value","styles","marginBottom","scrollAxis","options","registerParallaxProvider","customParallaxProviderMeta","globalParallaxProviderMeta","registerGlobalParallaxProvider","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAewBA;MACtBC,aAAAA;MACAC,gBAAAA;MACAC,uBAAAA;MACAC,gBAAAA;MACAC,iBAAAA;AAEA,MAAMC,QAAQ,GAAGC,gBAAU,CAACC,yBAAD,CAA3B;AACA,MAAMC,UAAU,GAAGF,gBAAU,CAACG,mCAAD,CAAV,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0BAFe,GAEeP,oBAFf,CAAjB;AAID;AACF;AAED,IAAaQ,0BAA0B,GACrC;AACE5C,EAAAA,IAAI,EAAE,0BADR;AAEEC,EAAAA,WAAW,EAAE,mBAFf;AAGEC,EAAAA,UAAU,EAAE,yBAHd;AAIEC,EAAAA,UAAU,EAAE,oCAJd;AAKEC,EAAAA,KAAK,EAAE;AACLoC,IAAAA,UAAU,EAAE;AACVnC,MAAAA,IAAI,EAAE,QADI;AAEVK,MAAAA,WAAW,EAAE,uDAFH;AAGV+B,MAAAA,OAAO,EAAE,CAAC,UAAD,EAAa,YAAb,CAHC;AAIVxC,MAAAA,WAAW,EAAE;AAJH;AADP;AALT,CADK;AAgBP,SAAgB4C,+BACdhC,QACA8B;AAEA,MAAI9B,MAAJ,EAAY;AACVA,IAAAA,MAAM,CAACiC,qBAAP,CACEZ,uBADF,EAEES,0BAFF,WAEEA,0BAFF,GAEgCC,0BAFhC;AAID,GALD,MAKO;AACLE,IAAAA,qBAAqB,CACnBZ,uBADmB,EAEnBS,0BAFmB,WAEnBA,0BAFmB,GAEWC,0BAFX,CAArB;AAID;AACF;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"react-scroll-parallax.cjs.development.js","sources":["../src/ParallaxWrapper.tsx","../src/ParallaxProvider.tsx"],"sourcesContent":["import { PlasmicCanvasContext } from \"@plasmicapp/host\";\nimport registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React, { useContext } from \"react\";\nimport { Parallax, ParallaxContext } from \"react-scroll-parallax\";\n\nexport interface ParallaxWrapperProps {\n speed?: number;\n disabled?: boolean;\n previewInEditor?: boolean;\n children: React.ReactNode;\n className?: string;\n}\n\nexport default function ParallaxWrapper({\n speed,\n disabled,\n previewInEditor,\n children,\n className,\n}: ParallaxWrapperProps) {\n const inEditor = useContext(PlasmicCanvasContext);\n const hasContext = useContext(ParallaxContext) != null;\n const isServer = typeof window === \"undefined\";\n if (!hasContext && !isServer) {\n throw new Error(\n \"Scroll Parallax can only be instantiated somewhere inside the Parallax Provider\"\n );\n }\n return (\n <Parallax\n disabled={disabled || (inEditor && !previewInEditor)}\n speed={speed}\n className={className}\n >\n {children}\n </Parallax>\n );\n}\n\n/**\n * We're keeping the old registration without attachments to avoid confusion\n * due to the parallax custom behavior not working in old projects that didn't\n * make use of global contexts (so simply adding the custom behavior would\n * break it and it wouldn't be clear that the user should also add a\n * `ParallaxProvider`).\n */\nexport const deprecated_parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> =\n {\n name: \"hostless-scroll-parallax\",\n displayName: \"Scroll Parallax\",\n importName: \"ParallaxWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"img\",\n src: \"https://placekitten.com/300/200\",\n style: {\n maxWidth: \"100%\",\n },\n },\n },\n speed: {\n type: \"number\",\n description:\n \"How much to speed up or slow down this element while scrolling. Try -20 for slower, 20 for faster.\",\n defaultValue: 20,\n },\n disabled: {\n type: \"boolean\",\n description: \"Disables the parallax effect.\",\n },\n previewInEditor: {\n type: \"boolean\",\n description: \"Enable the parallax effect in the editor.\",\n },\n },\n defaultStyles: {\n maxWidth: \"100%\",\n },\n };\n\nexport function deprecated_registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n }\n}\n\n/**\n * The new registration is only setting `isAttachment: true`.\n */\nexport const parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> = {\n ...deprecated_parallaxWrapperMeta,\n isAttachment: true,\n};\n\nexport function registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport React, { useEffect, useRef } from \"react\";\nimport { ParallaxProvider, useController } from \"react-scroll-parallax\";\nimport { ParallaxProviderProps } from \"react-scroll-parallax/dist/components/ParallaxProvider/types\";\nimport ResizeObserver from \"resize-observer-polyfill\";\n\n/**\n * This is required to ensure the parallax scrolling works correctly, since if\n * (for instance) images load after the parallax wrapper has calculated the\n * dimensions of the space, it will result in incorrect parallax scrolling\n * amounts.\n *\n * This is not great since we need to mutation-observe the whole section of the\n * document (which may be large), but we can probably optimize this in the\n * future.\n */\nfunction ParallaxCacheUpdate({ children }: React.PropsWithChildren<{}>) {\n const parallaxController = useController();\n const ref = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (ref.current?.parentElement) {\n const targetNode = ref.current.parentElement;\n const observer = new ResizeObserver(() => {\n if (parallaxController) {\n parallaxController.update();\n }\n });\n observer.observe(targetNode);\n return () => {\n observer.disconnect();\n };\n }\n return () => {};\n }, [ref.current]);\n\n return (\n <div style={{ display: \"contents\" }} ref={ref}>\n {children}\n </div>\n );\n}\n\nexport function ParallaxProviderWrapper({\n children,\n ...props\n}: React.PropsWithChildren<ParallaxProviderProps>) {\n return (\n <ParallaxProvider {...props}>\n <ParallaxCacheUpdate>{children}</ParallaxCacheUpdate>\n </ParallaxProvider>\n );\n}\n\n/**\n * @deprecated use `globalParallaxProviderMeta` instead.\n */\nexport const parallaxProviderMeta: ComponentMeta<ParallaxProviderProps> = {\n name: \"hostless-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"text\",\n value:\n \"Wrap any element in a Scroll Parallax component. Ensure they're all inside this Parallax Provider. Example:\",\n styles: {\n marginBottom: \"20px\",\n },\n },\n {\n type: \"component\",\n name: \"hostless-scroll-parallax\",\n },\n ],\n },\n },\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n};\n\n/**\n * @deprecated use `registerGlobalParallaxProvider` instead.\n */\nexport function registerParallaxProvider(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxProviderMeta?: ComponentMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n } else {\n registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n }\n}\n\nexport const globalParallaxProviderMeta: GlobalContextMeta<ParallaxProviderProps> =\n {\n name: \"global-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n };\n\nexport function registerGlobalParallaxProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customParallaxProviderMeta?: GlobalContextMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n } else {\n registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n }\n}\n"],"names":["ParallaxWrapper","speed","disabled","previewInEditor","children","className","inEditor","useContext","PlasmicCanvasContext","hasContext","ParallaxContext","isServer","window","Error","React","Parallax","deprecated_parallaxWrapperMeta","name","displayName","importName","importPath","props","type","defaultValue","src","style","maxWidth","description","defaultStyles","deprecated_registerParallaxWrapper","loader","customParallaxWrapperMeta","registerComponent","parallaxWrapperMeta","isAttachment","registerParallaxWrapper","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","display","ParallaxProviderWrapper","ParallaxProvider","parallaxProviderMeta","value","styles","marginBottom","scrollAxis","options","registerParallaxProvider","customParallaxProviderMeta","globalParallaxProviderMeta","registerGlobalParallaxProvider","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAewBA,eAAe;MACrCC,KAAK,QAALA,KAAK;IACLC,QAAQ,QAARA,QAAQ;IACRC,eAAe,QAAfA,eAAe;IACfC,QAAQ,QAARA,QAAQ;IACRC,SAAS,QAATA,SAAS;EAET,IAAMC,QAAQ,GAAGC,gBAAU,CAACC,yBAAoB,CAAC;EACjD,IAAMC,UAAU,GAAGF,gBAAU,CAACG,mCAAe,CAAC,IAAI,IAAI;EACtD,IAAMC,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;EAC9C,IAAI,CAACH,UAAU,IAAI,CAACE,QAAQ,EAAE;IAC5B,MAAM,IAAIE,KAAK,CACb,iFAAiF,CAClF;;EAEH,OACEC,6BAACC,4BAAQ;IACPb,QAAQ,EAAEA,QAAQ,IAAKI,QAAQ,IAAI,CAACH,eAAgB;IACpDF,KAAK,EAAEA,KAAK;IACZI,SAAS,EAAEA;KAEVD,QAAQ,CACA;AAEf;AAEA;;;;;;;IAOaY,8BAA8B,GACzC;EACEC,IAAI,EAAE,0BAA0B;EAChCC,WAAW,EAAE,iBAAiB;EAC9BC,UAAU,EAAE,iBAAiB;EAC7BC,UAAU,EAAE,oCAAoC;EAChDC,KAAK,EAAE;IACLjB,QA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AC;MACnCxC,WAAW,EAAE;;;CAGlB;AAED;;;AAGA,SAAgByC,wBAAwB,CACtC7B,MAAwD,EACxD8B,0BAAiE;EAEjE,IAAI9B,MAAM,EAAE;IACVA,MAAM,CAACE,iBAAiB,CACtBmB,uBAAuB,EACvBS,0BAA0B,WAA1BA,0BAA0B,GAAIP,oBAAoB,CACnD;GACF,MAAM;IACLrB,iBAAiB,CACfmB,uBAAuB,EACvBS,0BAA0B,WAA1BA,0BAA0B,GAAIP,oBAAoB,CACnD;;AAEL;AAEA,IAAaQ,0BAA0B,GACrC;EACE5C,IAAI,EAAE,0BAA0B;EAChCC,WAAW,EAAE,mBAAmB;EAChCC,UAAU,EAAE,yBAAyB;EACrCC,UAAU,EAAE,oCAAoC;EAChDC,KAAK,EAAE;IACLoC,UAAU,EAAE;MACVnC,IAAI,EAAE,QAAQ;MACdK,WAAW,EAAE,uDAAuD;MACpE+B,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;MACnCxC,WAAW,EAAE;;;CAGlB;AAEH,SAAgB4C,8BAA8B,CAC5ChC,MAAgE,EAChE8B,0BAAqE;EAErE,IAAI9B,MAAM,EAAE;IACVA,MAAM,CAACiC,qBAAqB,CAC1BZ,uBAAuB,EACvBS,0BAA0B,WAA1BA,0BAA0B,GAAIC,0BAA0B,CACzD;GACF,MAAM;IACLE,qBAAqB,CACnBZ,uBAAuB,EACvBS,0BAA0B,WAA1BA,0BAA0B,GAAIC,0BAA0B,CACzD;;AAEL;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@plasmicapp/host"),a=e(require("@plasmicapp/host/registerComponent")),l=require("react"),t=e(l),o=require("react-scroll-parallax"),n=e(require("@plasmicapp/host/registerGlobalContext")),i=e(require("resize-observer-polyfill"));function s(){return(s=Object.assign
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@plasmicapp/host"),a=e(require("@plasmicapp/host/registerComponent")),l=require("react"),t=e(l),o=require("react-scroll-parallax"),n=e(require("@plasmicapp/host/registerGlobalContext")),i=e(require("resize-observer-polyfill"));function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e}).apply(this,arguments)}function p(e){var a=e.speed,n=e.disabled,i=e.previewInEditor,s=e.children,p=e.className,c=l.useContext(r.PlasmicCanvasContext),d=null!=l.useContext(o.ParallaxContext),u="undefined"==typeof window;if(!d&&!u)throw new Error("Scroll Parallax can only be instantiated somewhere inside the Parallax Provider");return t.createElement(o.Parallax,{disabled:n||c&&!i,speed:a,className:p},s)}var c={name:"hostless-scroll-parallax",displayName:"Scroll Parallax",importName:"ParallaxWrapper",importPath:"@plasmicpkgs/react-scroll-parallax",props:{children:{type:"slot",defaultValue:{type:"img",src:"https://placekitten.com/300/200",style:{maxWidth:"100%"}}},speed:{type:"number",description:"How much to speed up or slow down this element while scrolling. Try -20 for slower, 20 for faster.",defaultValue:20},disabled:{type:"boolean",description:"Disables the parallax effect."},previewInEditor:{type:"boolean",description:"Enable the parallax effect in the editor."}},defaultStyles:{maxWidth:"100%"}},d=s({},c,{isAttachment:!0}),u=["children"];function x(e){var r=e.children,a=o.useController(),n=l.useRef(null);return l.useEffect((function(){var e;if(null!=(e=n.current)&&e.parentElement){var r=n.current.parentElement,l=new i((function(){a&&a.update()}));return l.observe(r),function(){l.disconnect()}}return function(){}}),[n.current]),t.createElement("div",{style:{display:"contents"},ref:n},r)}function m(e){var r=e.children,a=function(e,r){if(null==e)return{};var a,l,t={},o=Object.keys(e);for(l=0;l<o.length;l++)r.indexOf(a=o[l])>=0||(t[a]=e[a]);return t}(e,u);return t.createElement(o.ParallaxProvider,Object.assign({},a),t.createElement(x,null,r))}var f={name:"hostless-parallax-provider",displayName:"Parallax Provider",importName:"ParallaxProviderWrapper",importPath:"@plasmicpkgs/react-scroll-parallax",props:{children:{type:"slot",defaultValue:{type:"vbox",children:[{type:"text",value:"Wrap any element in a Scroll Parallax component. Ensure they're all inside this Parallax Provider. Example:",styles:{marginBottom:"20px"}},{type:"component",name:"hostless-scroll-parallax"}]}},scrollAxis:{type:"choice",description:"Scroll axis for setting horizontal/vertical scrolling",options:["vertical","horizontal"],displayName:"Scroll Axis"}}},h={name:"global-parallax-provider",displayName:"Parallax Provider",importName:"ParallaxProviderWrapper",importPath:"@plasmicpkgs/react-scroll-parallax",props:{scrollAxis:{type:"choice",description:"Scroll axis for setting horizontal/vertical scrolling",options:["vertical","horizontal"],displayName:"Scroll Axis"}}};exports.ParallaxProviderWrapper=m,exports.ParallaxWrapper=p,exports.deprecated_parallaxWrapperMeta=c,exports.deprecated_registerParallaxWrapper=function(e,r){e?e.registerComponent(p,null!=r?r:c):a(p,null!=r?r:c)},exports.globalParallaxProviderMeta=h,exports.parallaxProviderMeta=f,exports.parallaxWrapperMeta=d,exports.registerGlobalParallaxProvider=function(e,r){e?e.registerGlobalContext(m,null!=r?r:h):n(m,null!=r?r:h)},exports.registerParallaxProvider=function(e,r){e?e.registerComponent(m,null!=r?r:f):a(m,null!=r?r:f)},exports.registerParallaxWrapper=function(e,r){e?e.registerComponent(p,null!=r?r:d):a(p,null!=r?r:d)};
|
|
2
2
|
//# sourceMappingURL=react-scroll-parallax.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-scroll-parallax.cjs.production.min.js","sources":["../src/ParallaxWrapper.tsx","../src/ParallaxProvider.tsx"],"sourcesContent":["import { PlasmicCanvasContext } from \"@plasmicapp/host\";\nimport registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React, { useContext } from \"react\";\nimport { Parallax, ParallaxContext } from \"react-scroll-parallax\";\n\nexport interface ParallaxWrapperProps {\n speed?: number;\n disabled?: boolean;\n previewInEditor?: boolean;\n children: React.ReactNode;\n className?: string;\n}\n\nexport default function ParallaxWrapper({\n speed,\n disabled,\n previewInEditor,\n children,\n className,\n}: ParallaxWrapperProps) {\n const inEditor = useContext(PlasmicCanvasContext);\n const hasContext = useContext(ParallaxContext) != null;\n const isServer = typeof window === \"undefined\";\n if (!hasContext && !isServer) {\n throw new Error(\n \"Scroll Parallax can only be instantiated somewhere inside the Parallax Provider\"\n );\n }\n return (\n <Parallax\n disabled={disabled || (inEditor && !previewInEditor)}\n speed={speed}\n className={className}\n >\n {children}\n </Parallax>\n );\n}\n\n/**\n * We're keeping the old registration without attachments to avoid confusion\n * due to the parallax custom behavior not working in old projects that didn't\n * make use of global contexts (so simply adding the custom behavior would\n * break it and it wouldn't be clear that the user should also add a\n * `ParallaxProvider`).\n */\nexport const deprecated_parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> =\n {\n name: \"hostless-scroll-parallax\",\n displayName: \"Scroll Parallax\",\n importName: \"ParallaxWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"img\",\n src: \"https://placekitten.com/300/200\",\n style: {\n maxWidth: \"100%\",\n },\n },\n },\n speed: {\n type: \"number\",\n description:\n \"How much to speed up or slow down this element while scrolling. Try -20 for slower, 20 for faster.\",\n defaultValue: 20,\n },\n disabled: {\n type: \"boolean\",\n description: \"Disables the parallax effect.\",\n },\n previewInEditor: {\n type: \"boolean\",\n description: \"Enable the parallax effect in the editor.\",\n },\n },\n defaultStyles: {\n maxWidth: \"100%\",\n },\n };\n\nexport function deprecated_registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n }\n}\n\n/**\n * The new registration is only setting `isAttachment: true`.\n */\nexport const parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> = {\n ...deprecated_parallaxWrapperMeta,\n isAttachment: true,\n};\n\nexport function registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport React, { useEffect, useRef } from \"react\";\nimport { ParallaxProvider, useController } from \"react-scroll-parallax\";\nimport { ParallaxProviderProps } from \"react-scroll-parallax/dist/components/ParallaxProvider/types\";\nimport ResizeObserver from \"resize-observer-polyfill\";\n\n/**\n * This is required to ensure the parallax scrolling works correctly, since if\n * (for instance) images load after the parallax wrapper has calculated the\n * dimensions of the space, it will result in incorrect parallax scrolling\n * amounts.\n *\n * This is not great since we need to mutation-observe the whole section of the\n * document (which may be large), but we can probably optimize this in the\n * future.\n */\nfunction ParallaxCacheUpdate({ children }: React.PropsWithChildren<{}>) {\n const parallaxController = useController();\n const ref = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (ref.current?.parentElement) {\n const targetNode = ref.current.parentElement;\n const observer = new ResizeObserver(() => {\n if (parallaxController) {\n parallaxController.update();\n }\n });\n observer.observe(targetNode);\n return () => {\n observer.disconnect();\n };\n }\n return () => {};\n }, [ref.current]);\n\n return (\n <div style={{ display: \"contents\" }} ref={ref}>\n {children}\n </div>\n );\n}\n\nexport function ParallaxProviderWrapper({\n children,\n ...props\n}: React.PropsWithChildren<ParallaxProviderProps>) {\n return (\n <ParallaxProvider {...props}>\n <ParallaxCacheUpdate>{children}</ParallaxCacheUpdate>\n </ParallaxProvider>\n );\n}\n\n/**\n * @deprecated use `globalParallaxProviderMeta` instead.\n */\nexport const parallaxProviderMeta: ComponentMeta<ParallaxProviderProps> = {\n name: \"hostless-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"text\",\n value:\n \"Wrap any element in a Scroll Parallax component. Ensure they're all inside this Parallax Provider. Example:\",\n styles: {\n marginBottom: \"20px\",\n },\n },\n {\n type: \"component\",\n name: \"hostless-scroll-parallax\",\n },\n ],\n },\n },\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n};\n\n/**\n * @deprecated use `registerGlobalParallaxProvider` instead.\n */\nexport function registerParallaxProvider(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxProviderMeta?: ComponentMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n } else {\n registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n }\n}\n\nexport const globalParallaxProviderMeta: GlobalContextMeta<ParallaxProviderProps> =\n {\n name: \"global-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n };\n\nexport function registerGlobalParallaxProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customParallaxProviderMeta?: GlobalContextMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n } else {\n registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n }\n}\n"],"names":["ParallaxWrapper","speed","disabled","previewInEditor","children","className","inEditor","useContext","PlasmicCanvasContext","hasContext","ParallaxContext","isServer","window","Error","React","Parallax","deprecated_parallaxWrapperMeta","name","displayName","importName","importPath","props","type","defaultValue","src","style","maxWidth","description","defaultStyles","parallaxWrapperMeta","isAttachment","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","current","_ref$current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","display","ParallaxProviderWrapper","ParallaxProvider","parallaxProviderMeta","value","styles","marginBottom","scrollAxis","options","globalParallaxProviderMeta","loader","customParallaxWrapperMeta","registerComponent","customParallaxProviderMeta","registerGlobalContext"],"mappings":"olBAewBA,SACtBC,IAAAA,MACAC,IAAAA,SACAC,IAAAA,gBACAC,IAAAA,SACAC,IAAAA,UAEMC,EAAWC,aAAWC,wBACtBC,EAA4C,MAA/BF,aAAWG,mBACxBC,EAA6B,oBAAXC,WACnBH,IAAeE,QACZ,IAAIE,MACR,0FAIFC,gBAACC,YACCb,SAAUA,GAAaI,IAAaH,EACpCF,MAAOA,EACPI,UAAWA,GAEVD,OAYMY,EACX,CACEC,KAAM,2BACNC,YAAa,kBACbC,WAAY,kBACZC,WAAY,qCACZC,MAAO,CACLjB,SAAU,CACRkB,KAAM,OACNC,aAAc,CACZD,KAAM,MACNE,IAAK,kCACLC,MAAO,CACLC,SAAU,UAIhBzB,MAAO,CACLqB,KAAM,SACNK,YACE,qGACFJ,aAAc,IAEhBrB,SAAU,CACRoB,KAAM,UACNK,YAAa,iCAEfxB,gBAAiB,CACfmB,KAAM,UACNK,YAAa,8CAGjBC,cAAe,CACbF,S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EAAAA,EAA8BV,6CDDlCO,EACAC,GAEID,EACFA,EAAOE,kBACL1D,QACAyD,EAAAA,EAA6B5B,GAG/B6B,EACE1D,QACAyD,EAAAA,EAA6B5B"}
|
|
1
|
+
{"version":3,"file":"react-scroll-parallax.cjs.production.min.js","sources":["../src/ParallaxWrapper.tsx","../src/ParallaxProvider.tsx"],"sourcesContent":["import { PlasmicCanvasContext } from \"@plasmicapp/host\";\nimport registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React, { useContext } from \"react\";\nimport { Parallax, ParallaxContext } from \"react-scroll-parallax\";\n\nexport interface ParallaxWrapperProps {\n speed?: number;\n disabled?: boolean;\n previewInEditor?: boolean;\n children: React.ReactNode;\n className?: string;\n}\n\nexport default function ParallaxWrapper({\n speed,\n disabled,\n previewInEditor,\n children,\n className,\n}: ParallaxWrapperProps) {\n const inEditor = useContext(PlasmicCanvasContext);\n const hasContext = useContext(ParallaxContext) != null;\n const isServer = typeof window === \"undefined\";\n if (!hasContext && !isServer) {\n throw new Error(\n \"Scroll Parallax can only be instantiated somewhere inside the Parallax Provider\"\n );\n }\n return (\n <Parallax\n disabled={disabled || (inEditor && !previewInEditor)}\n speed={speed}\n className={className}\n >\n {children}\n </Parallax>\n );\n}\n\n/**\n * We're keeping the old registration without attachments to avoid confusion\n * due to the parallax custom behavior not working in old projects that didn't\n * make use of global contexts (so simply adding the custom behavior would\n * break it and it wouldn't be clear that the user should also add a\n * `ParallaxProvider`).\n */\nexport const deprecated_parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> =\n {\n name: \"hostless-scroll-parallax\",\n displayName: \"Scroll Parallax\",\n importName: \"ParallaxWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"img\",\n src: \"https://placekitten.com/300/200\",\n style: {\n maxWidth: \"100%\",\n },\n },\n },\n speed: {\n type: \"number\",\n description:\n \"How much to speed up or slow down this element while scrolling. Try -20 for slower, 20 for faster.\",\n defaultValue: 20,\n },\n disabled: {\n type: \"boolean\",\n description: \"Disables the parallax effect.\",\n },\n previewInEditor: {\n type: \"boolean\",\n description: \"Enable the parallax effect in the editor.\",\n },\n },\n defaultStyles: {\n maxWidth: \"100%\",\n },\n };\n\nexport function deprecated_registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n }\n}\n\n/**\n * The new registration is only setting `isAttachment: true`.\n */\nexport const parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> = {\n ...deprecated_parallaxWrapperMeta,\n isAttachment: true,\n};\n\nexport function registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport React, { useEffect, useRef } from \"react\";\nimport { ParallaxProvider, useController } from \"react-scroll-parallax\";\nimport { ParallaxProviderProps } from \"react-scroll-parallax/dist/components/ParallaxProvider/types\";\nimport ResizeObserver from \"resize-observer-polyfill\";\n\n/**\n * This is required to ensure the parallax scrolling works correctly, since if\n * (for instance) images load after the parallax wrapper has calculated the\n * dimensions of the space, it will result in incorrect parallax scrolling\n * amounts.\n *\n * This is not great since we need to mutation-observe the whole section of the\n * document (which may be large), but we can probably optimize this in the\n * future.\n */\nfunction ParallaxCacheUpdate({ children }: React.PropsWithChildren<{}>) {\n const parallaxController = useController();\n const ref = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (ref.current?.parentElement) {\n const targetNode = ref.current.parentElement;\n const observer = new ResizeObserver(() => {\n if (parallaxController) {\n parallaxController.update();\n }\n });\n observer.observe(targetNode);\n return () => {\n observer.disconnect();\n };\n }\n return () => {};\n }, [ref.current]);\n\n return (\n <div style={{ display: \"contents\" }} ref={ref}>\n {children}\n </div>\n );\n}\n\nexport function ParallaxProviderWrapper({\n children,\n ...props\n}: React.PropsWithChildren<ParallaxProviderProps>) {\n return (\n <ParallaxProvider {...props}>\n <ParallaxCacheUpdate>{children}</ParallaxCacheUpdate>\n </ParallaxProvider>\n );\n}\n\n/**\n * @deprecated use `globalParallaxProviderMeta` instead.\n */\nexport const parallaxProviderMeta: ComponentMeta<ParallaxProviderProps> = {\n name: \"hostless-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"text\",\n value:\n \"Wrap any element in a Scroll Parallax component. Ensure they're all inside this Parallax Provider. Example:\",\n styles: {\n marginBottom: \"20px\",\n },\n },\n {\n type: \"component\",\n name: \"hostless-scroll-parallax\",\n },\n ],\n },\n },\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n};\n\n/**\n * @deprecated use `registerGlobalParallaxProvider` instead.\n */\nexport function registerParallaxProvider(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxProviderMeta?: ComponentMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n } else {\n registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n }\n}\n\nexport const globalParallaxProviderMeta: GlobalContextMeta<ParallaxProviderProps> =\n {\n name: \"global-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n };\n\nexport function registerGlobalParallaxProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customParallaxProviderMeta?: GlobalContextMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n } else {\n registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n }\n}\n"],"names":["ParallaxWrapper","speed","disabled","previewInEditor","children","className","inEditor","useContext","PlasmicCanvasContext","hasContext","ParallaxContext","isServer","window","Error","React","Parallax","deprecated_parallaxWrapperMeta","name","displayName","importName","importPath","props","type","defaultValue","src","style","maxWidth","description","defaultStyles","parallaxWrapperMeta","isAttachment","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","current","_ref$current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","display","ParallaxProviderWrapper","ParallaxProvider","parallaxProviderMeta","value","styles","marginBottom","scrollAxis","options","globalParallaxProviderMeta","loader","customParallaxWrapperMeta","registerComponent","customParallaxProviderMeta","registerGlobalContext"],"mappings":"wmBAewBA,SACtBC,IAAAA,MACAC,IAAAA,SACAC,IAAAA,gBACAC,IAAAA,SACAC,IAAAA,UAEMC,EAAWC,aAAWC,wBACtBC,EAA4C,MAA/BF,aAAWG,mBACxBC,EAA6B,oBAAXC,OACxB,IAAKH,IAAeE,EAClB,MAAM,IAAIE,M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CACEtC,KAAM,2BACNC,YAAa,oBACbC,WAAY,0BACZC,WAAY,qCACZC,MAAO,CACLgC,WAAY,CACV/B,KAAM,SACNK,YAAa,wDACb2B,QAAS,CAAC,WAAY,cACtBpC,YAAa,0KD1CnBsC,EACAC,GAEID,EACFA,EAAOE,kBACL1D,QACAyD,EAAAA,EAA6BzC,GAG/B0C,EACE1D,QACAyD,EAAAA,EAA6BzC,sJCqCjCwC,EACAG,GAEIH,EACFA,EAAOI,sBACLb,QACAY,EAAAA,EAA8BJ,GAGhCK,EACEb,QACAY,EAAAA,EAA8BJ,8CA5ClCC,EACAG,GAEIH,EACFA,EAAOE,kBACLX,QACAY,EAAAA,EAA8BV,GAGhCS,EACEX,QACAY,EAAAA,EAA8BV,6CDDlCO,EACAC,GAEID,EACFA,EAAOE,kBACL1D,QACAyD,EAAAA,EAA6B5B,GAG/B6B,EACE1D,QACAyD,EAAAA,EAA6B5B"}
|
|
@@ -6,52 +6,44 @@ import registerGlobalContext from '@plasmicapp/host/registerGlobalContext';
|
|
|
6
6
|
import ResizeObserver from 'resize-observer-polyfill';
|
|
7
7
|
|
|
8
8
|
function _extends() {
|
|
9
|
-
_extends = Object.assign
|
|
9
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
10
10
|
for (var i = 1; i < arguments.length; i++) {
|
|
11
11
|
var source = arguments[i];
|
|
12
|
-
|
|
13
12
|
for (var key in source) {
|
|
14
13
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
15
14
|
target[key] = source[key];
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
return target;
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
return _extends.apply(this, arguments);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
27
23
|
if (source == null) return {};
|
|
28
24
|
var target = {};
|
|
29
25
|
var sourceKeys = Object.keys(source);
|
|
30
26
|
var key, i;
|
|
31
|
-
|
|
32
27
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
33
28
|
key = sourceKeys[i];
|
|
34
29
|
if (excluded.indexOf(key) >= 0) continue;
|
|
35
30
|
target[key] = source[key];
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
return target;
|
|
39
33
|
}
|
|
40
34
|
|
|
41
35
|
function ParallaxWrapper(_ref) {
|
|
42
36
|
var speed = _ref.speed,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
disabled = _ref.disabled,
|
|
38
|
+
previewInEditor = _ref.previewInEditor,
|
|
39
|
+
children = _ref.children,
|
|
40
|
+
className = _ref.className;
|
|
47
41
|
var inEditor = useContext(PlasmicCanvasContext);
|
|
48
42
|
var hasContext = useContext(ParallaxContext) != null;
|
|
49
43
|
var isServer = typeof window === "undefined";
|
|
50
|
-
|
|
51
44
|
if (!hasContext && !isServer) {
|
|
52
45
|
throw new Error("Scroll Parallax can only be instantiated somewhere inside the Parallax Provider");
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
return React.createElement(Parallax, {
|
|
56
48
|
disabled: disabled || inEditor && !previewInEditor,
|
|
57
49
|
speed: speed,
|
|
@@ -65,7 +57,6 @@ function ParallaxWrapper(_ref) {
|
|
|
65
57
|
* break it and it wouldn't be clear that the user should also add a
|
|
66
58
|
* `ParallaxProvider`).
|
|
67
59
|
*/
|
|
68
|
-
|
|
69
60
|
var deprecated_parallaxWrapperMeta = {
|
|
70
61
|
name: "hostless-scroll-parallax",
|
|
71
62
|
displayName: "Scroll Parallax",
|
|
@@ -110,7 +101,6 @@ function deprecated_registerParallaxWrapper(loader, customParallaxWrapperMeta) {
|
|
|
110
101
|
/**
|
|
111
102
|
* The new registration is only setting `isAttachment: true`.
|
|
112
103
|
*/
|
|
113
|
-
|
|
114
104
|
var parallaxWrapperMeta = /*#__PURE__*/_extends({}, deprecated_parallaxWrapperMeta, {
|
|
115
105
|
isAttachment: true
|
|
116
106
|
});
|
|
@@ -133,14 +123,12 @@ var _excluded = ["children"];
|
|
|
133
123
|
* document (which may be large), but we can probably optimize this in the
|
|
134
124
|
* future.
|
|
135
125
|
*/
|
|
136
|
-
|
|
137
126
|
function ParallaxCacheUpdate(_ref) {
|
|
138
127
|
var children = _ref.children;
|
|
139
128
|
var parallaxController = useController();
|
|
140
129
|
var ref = useRef(null);
|
|
141
130
|
useEffect(function () {
|
|
142
131
|
var _ref$current;
|
|
143
|
-
|
|
144
132
|
if ((_ref$current = ref.current) != null && _ref$current.parentElement) {
|
|
145
133
|
var targetNode = ref.current.parentElement;
|
|
146
134
|
var observer = new ResizeObserver(function () {
|
|
@@ -153,7 +141,6 @@ function ParallaxCacheUpdate(_ref) {
|
|
|
153
141
|
observer.disconnect();
|
|
154
142
|
};
|
|
155
143
|
}
|
|
156
|
-
|
|
157
144
|
return function () {};
|
|
158
145
|
}, [ref.current]);
|
|
159
146
|
return React.createElement("div", {
|
|
@@ -163,17 +150,14 @@ function ParallaxCacheUpdate(_ref) {
|
|
|
163
150
|
ref: ref
|
|
164
151
|
}, children);
|
|
165
152
|
}
|
|
166
|
-
|
|
167
153
|
function ParallaxProviderWrapper(_ref2) {
|
|
168
154
|
var children = _ref2.children,
|
|
169
|
-
|
|
170
|
-
|
|
155
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
171
156
|
return React.createElement(ParallaxProvider, Object.assign({}, props), React.createElement(ParallaxCacheUpdate, null, children));
|
|
172
157
|
}
|
|
173
158
|
/**
|
|
174
159
|
* @deprecated use `globalParallaxProviderMeta` instead.
|
|
175
160
|
*/
|
|
176
|
-
|
|
177
161
|
var parallaxProviderMeta = {
|
|
178
162
|
name: "hostless-parallax-provider",
|
|
179
163
|
displayName: "Parallax Provider",
|
|
@@ -207,7 +191,6 @@ var parallaxProviderMeta = {
|
|
|
207
191
|
/**
|
|
208
192
|
* @deprecated use `registerGlobalParallaxProvider` instead.
|
|
209
193
|
*/
|
|
210
|
-
|
|
211
194
|
function registerParallaxProvider(loader, customParallaxProviderMeta) {
|
|
212
195
|
if (loader) {
|
|
213
196
|
loader.registerComponent(ParallaxProviderWrapper, customParallaxProviderMeta != null ? customParallaxProviderMeta : parallaxProviderMeta);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-scroll-parallax.esm.js","sources":["../src/ParallaxWrapper.tsx","../src/ParallaxProvider.tsx"],"sourcesContent":["import { PlasmicCanvasContext } from \"@plasmicapp/host\";\nimport registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React, { useContext } from \"react\";\nimport { Parallax, ParallaxContext } from \"react-scroll-parallax\";\n\nexport interface ParallaxWrapperProps {\n speed?: number;\n disabled?: boolean;\n previewInEditor?: boolean;\n children: React.ReactNode;\n className?: string;\n}\n\nexport default function ParallaxWrapper({\n speed,\n disabled,\n previewInEditor,\n children,\n className,\n}: ParallaxWrapperProps) {\n const inEditor = useContext(PlasmicCanvasContext);\n const hasContext = useContext(ParallaxContext) != null;\n const isServer = typeof window === \"undefined\";\n if (!hasContext && !isServer) {\n throw new Error(\n \"Scroll Parallax can only be instantiated somewhere inside the Parallax Provider\"\n );\n }\n return (\n <Parallax\n disabled={disabled || (inEditor && !previewInEditor)}\n speed={speed}\n className={className}\n >\n {children}\n </Parallax>\n );\n}\n\n/**\n * We're keeping the old registration without attachments to avoid confusion\n * due to the parallax custom behavior not working in old projects that didn't\n * make use of global contexts (so simply adding the custom behavior would\n * break it and it wouldn't be clear that the user should also add a\n * `ParallaxProvider`).\n */\nexport const deprecated_parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> =\n {\n name: \"hostless-scroll-parallax\",\n displayName: \"Scroll Parallax\",\n importName: \"ParallaxWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"img\",\n src: \"https://placekitten.com/300/200\",\n style: {\n maxWidth: \"100%\",\n },\n },\n },\n speed: {\n type: \"number\",\n description:\n \"How much to speed up or slow down this element while scrolling. Try -20 for slower, 20 for faster.\",\n defaultValue: 20,\n },\n disabled: {\n type: \"boolean\",\n description: \"Disables the parallax effect.\",\n },\n previewInEditor: {\n type: \"boolean\",\n description: \"Enable the parallax effect in the editor.\",\n },\n },\n defaultStyles: {\n maxWidth: \"100%\",\n },\n };\n\nexport function deprecated_registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n }\n}\n\n/**\n * The new registration is only setting `isAttachment: true`.\n */\nexport const parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> = {\n ...deprecated_parallaxWrapperMeta,\n isAttachment: true,\n};\n\nexport function registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport React, { useEffect, useRef } from \"react\";\nimport { ParallaxProvider, useController } from \"react-scroll-parallax\";\nimport { ParallaxProviderProps } from \"react-scroll-parallax/dist/components/ParallaxProvider/types\";\nimport ResizeObserver from \"resize-observer-polyfill\";\n\n/**\n * This is required to ensure the parallax scrolling works correctly, since if\n * (for instance) images load after the parallax wrapper has calculated the\n * dimensions of the space, it will result in incorrect parallax scrolling\n * amounts.\n *\n * This is not great since we need to mutation-observe the whole section of the\n * document (which may be large), but we can probably optimize this in the\n * future.\n */\nfunction ParallaxCacheUpdate({ children }: React.PropsWithChildren<{}>) {\n const parallaxController = useController();\n const ref = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (ref.current?.parentElement) {\n const targetNode = ref.current.parentElement;\n const observer = new ResizeObserver(() => {\n if (parallaxController) {\n parallaxController.update();\n }\n });\n observer.observe(targetNode);\n return () => {\n observer.disconnect();\n };\n }\n return () => {};\n }, [ref.current]);\n\n return (\n <div style={{ display: \"contents\" }} ref={ref}>\n {children}\n </div>\n );\n}\n\nexport function ParallaxProviderWrapper({\n children,\n ...props\n}: React.PropsWithChildren<ParallaxProviderProps>) {\n return (\n <ParallaxProvider {...props}>\n <ParallaxCacheUpdate>{children}</ParallaxCacheUpdate>\n </ParallaxProvider>\n );\n}\n\n/**\n * @deprecated use `globalParallaxProviderMeta` instead.\n */\nexport const parallaxProviderMeta: ComponentMeta<ParallaxProviderProps> = {\n name: \"hostless-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"text\",\n value:\n \"Wrap any element in a Scroll Parallax component. Ensure they're all inside this Parallax Provider. Example:\",\n styles: {\n marginBottom: \"20px\",\n },\n },\n {\n type: \"component\",\n name: \"hostless-scroll-parallax\",\n },\n ],\n },\n },\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n};\n\n/**\n * @deprecated use `registerGlobalParallaxProvider` instead.\n */\nexport function registerParallaxProvider(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxProviderMeta?: ComponentMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n } else {\n registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n }\n}\n\nexport const globalParallaxProviderMeta: GlobalContextMeta<ParallaxProviderProps> =\n {\n name: \"global-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n };\n\nexport function registerGlobalParallaxProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customParallaxProviderMeta?: GlobalContextMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n } else {\n registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n }\n}\n"],"names":["ParallaxWrapper","speed","disabled","previewInEditor","children","className","inEditor","useContext","PlasmicCanvasContext","hasContext","ParallaxContext","isServer","window","Error","React","Parallax","deprecated_parallaxWrapperMeta","name","displayName","importName","importPath","props","type","defaultValue","src","style","maxWidth","description","defaultStyles","deprecated_registerParallaxWrapper","loader","customParallaxWrapperMeta","registerComponent","parallaxWrapperMeta","isAttachment","registerParallaxWrapper","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","display","ParallaxProviderWrapper","ParallaxProvider","parallaxProviderMeta","value","styles","marginBottom","scrollAxis","options","registerParallaxProvider","customParallaxProviderMeta","globalParallaxProviderMeta","registerGlobalParallaxProvider","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAewBA;MACtBC,aAAAA;MACAC,gBAAAA;MACAC,uBAAAA;M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EmB,uBADF,EAEES,0BAFF,WAEEA,0BAFF,GAEgCP,oBAFhC;AAID,GALD,MAKO;AACLrB,IAAAA,iBAAiB,CACfmB,uBADe,EAEfS,0BAFe,WAEfA,0BAFe,GAEeP,oBAFf,CAAjB;AAID;AACF;AAED,IAAaQ,0BAA0B,GACrC;AACE5C,EAAAA,IAAI,EAAE,0BADR;AAEEC,EAAAA,WAAW,EAAE,mBAFf;AAGEC,EAAAA,UAAU,EAAE,yBAHd;AAIEC,EAAAA,UAAU,EAAE,oCAJd;AAKEC,EAAAA,KAAK,EAAE;AACLoC,IAAAA,UAAU,EAAE;AACVnC,MAAAA,IAAI,EAAE,QADI;AAEVK,MAAAA,WAAW,EAAE,uDAFH;AAGV+B,MAAAA,OAAO,EAAE,CAAC,UAAD,EAAa,YAAb,CAHC;AAIVxC,MAAAA,WAAW,EAAE;AAJH;AADP;AALT,CADK;AAgBP,SAAgB4C,+BACdhC,QACA8B;AAEA,MAAI9B,MAAJ,EAAY;AACVA,IAAAA,MAAM,CAACiC,qBAAP,CACEZ,uBADF,EAEES,0BAFF,WAEEA,0BAFF,GAEgCC,0BAFhC;AAID,GALD,MAKO;AACLE,IAAAA,qBAAqB,CACnBZ,uBADmB,EAEnBS,0BAFmB,WAEnBA,0BAFmB,GAEWC,0BAFX,CAArB;AAID;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"react-scroll-parallax.esm.js","sources":["../src/ParallaxWrapper.tsx","../src/ParallaxProvider.tsx"],"sourcesContent":["import { PlasmicCanvasContext } from \"@plasmicapp/host\";\nimport registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React, { useContext } from \"react\";\nimport { Parallax, ParallaxContext } from \"react-scroll-parallax\";\n\nexport interface ParallaxWrapperProps {\n speed?: number;\n disabled?: boolean;\n previewInEditor?: boolean;\n children: React.ReactNode;\n className?: string;\n}\n\nexport default function ParallaxWrapper({\n speed,\n disabled,\n previewInEditor,\n children,\n className,\n}: ParallaxWrapperProps) {\n const inEditor = useContext(PlasmicCanvasContext);\n const hasContext = useContext(ParallaxContext) != null;\n const isServer = typeof window === \"undefined\";\n if (!hasContext && !isServer) {\n throw new Error(\n \"Scroll Parallax can only be instantiated somewhere inside the Parallax Provider\"\n );\n }\n return (\n <Parallax\n disabled={disabled || (inEditor && !previewInEditor)}\n speed={speed}\n className={className}\n >\n {children}\n </Parallax>\n );\n}\n\n/**\n * We're keeping the old registration without attachments to avoid confusion\n * due to the parallax custom behavior not working in old projects that didn't\n * make use of global contexts (so simply adding the custom behavior would\n * break it and it wouldn't be clear that the user should also add a\n * `ParallaxProvider`).\n */\nexport const deprecated_parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> =\n {\n name: \"hostless-scroll-parallax\",\n displayName: \"Scroll Parallax\",\n importName: \"ParallaxWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"img\",\n src: \"https://placekitten.com/300/200\",\n style: {\n maxWidth: \"100%\",\n },\n },\n },\n speed: {\n type: \"number\",\n description:\n \"How much to speed up or slow down this element while scrolling. Try -20 for slower, 20 for faster.\",\n defaultValue: 20,\n },\n disabled: {\n type: \"boolean\",\n description: \"Disables the parallax effect.\",\n },\n previewInEditor: {\n type: \"boolean\",\n description: \"Enable the parallax effect in the editor.\",\n },\n },\n defaultStyles: {\n maxWidth: \"100%\",\n },\n };\n\nexport function deprecated_registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? deprecated_parallaxWrapperMeta\n );\n }\n}\n\n/**\n * The new registration is only setting `isAttachment: true`.\n */\nexport const parallaxWrapperMeta: ComponentMeta<ParallaxWrapperProps> = {\n ...deprecated_parallaxWrapperMeta,\n isAttachment: true,\n};\n\nexport function registerParallaxWrapper(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxWrapperMeta?: ComponentMeta<ParallaxWrapperProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n } else {\n registerComponent(\n ParallaxWrapper,\n customParallaxWrapperMeta ?? parallaxWrapperMeta\n );\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport React, { useEffect, useRef } from \"react\";\nimport { ParallaxProvider, useController } from \"react-scroll-parallax\";\nimport { ParallaxProviderProps } from \"react-scroll-parallax/dist/components/ParallaxProvider/types\";\nimport ResizeObserver from \"resize-observer-polyfill\";\n\n/**\n * This is required to ensure the parallax scrolling works correctly, since if\n * (for instance) images load after the parallax wrapper has calculated the\n * dimensions of the space, it will result in incorrect parallax scrolling\n * amounts.\n *\n * This is not great since we need to mutation-observe the whole section of the\n * document (which may be large), but we can probably optimize this in the\n * future.\n */\nfunction ParallaxCacheUpdate({ children }: React.PropsWithChildren<{}>) {\n const parallaxController = useController();\n const ref = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (ref.current?.parentElement) {\n const targetNode = ref.current.parentElement;\n const observer = new ResizeObserver(() => {\n if (parallaxController) {\n parallaxController.update();\n }\n });\n observer.observe(targetNode);\n return () => {\n observer.disconnect();\n };\n }\n return () => {};\n }, [ref.current]);\n\n return (\n <div style={{ display: \"contents\" }} ref={ref}>\n {children}\n </div>\n );\n}\n\nexport function ParallaxProviderWrapper({\n children,\n ...props\n}: React.PropsWithChildren<ParallaxProviderProps>) {\n return (\n <ParallaxProvider {...props}>\n <ParallaxCacheUpdate>{children}</ParallaxCacheUpdate>\n </ParallaxProvider>\n );\n}\n\n/**\n * @deprecated use `globalParallaxProviderMeta` instead.\n */\nexport const parallaxProviderMeta: ComponentMeta<ParallaxProviderProps> = {\n name: \"hostless-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n children: [\n {\n type: \"text\",\n value:\n \"Wrap any element in a Scroll Parallax component. Ensure they're all inside this Parallax Provider. Example:\",\n styles: {\n marginBottom: \"20px\",\n },\n },\n {\n type: \"component\",\n name: \"hostless-scroll-parallax\",\n },\n ],\n },\n },\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n};\n\n/**\n * @deprecated use `registerGlobalParallaxProvider` instead.\n */\nexport function registerParallaxProvider(\n loader?: { registerComponent: typeof registerComponent },\n customParallaxProviderMeta?: ComponentMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n } else {\n registerComponent(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? parallaxProviderMeta\n );\n }\n}\n\nexport const globalParallaxProviderMeta: GlobalContextMeta<ParallaxProviderProps> =\n {\n name: \"global-parallax-provider\",\n displayName: \"Parallax Provider\",\n importName: \"ParallaxProviderWrapper\",\n importPath: \"@plasmicpkgs/react-scroll-parallax\",\n props: {\n scrollAxis: {\n type: \"choice\",\n description: \"Scroll axis for setting horizontal/vertical scrolling\",\n options: [\"vertical\", \"horizontal\"],\n displayName: \"Scroll Axis\",\n },\n },\n };\n\nexport function registerGlobalParallaxProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customParallaxProviderMeta?: GlobalContextMeta<ParallaxProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n } else {\n registerGlobalContext(\n ParallaxProviderWrapper,\n customParallaxProviderMeta ?? globalParallaxProviderMeta\n );\n }\n}\n"],"names":["ParallaxWrapper","speed","disabled","previewInEditor","children","className","inEditor","useContext","PlasmicCanvasContext","hasContext","ParallaxContext","isServer","window","Error","React","Parallax","deprecated_parallaxWrapperMeta","name","displayName","importName","importPath","props","type","defaultValue","src","style","maxWidth","description","defaultStyles","deprecated_registerParallaxWrapper","loader","customParallaxWrapperMeta","registerComponent","parallaxWrapperMeta","isAttachment","registerParallaxWrapper","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","display","ParallaxProviderWrapper","ParallaxProvider","parallaxProviderMeta","value","styles","marginBottom","scrollAxis","options","registerParallaxProvider","customParallaxProviderMeta","globalParallaxProviderMeta","registerGlobalParallaxProvider","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAewBA,eAAe;MACrCC,KAAK,QAALA,KAAK;IACLC,QAAQ,QAARA,QAAQ;IACRC,eAAe,QAAfA,eAAe;IACfC,QAAQ,QAARA,QAAQ;IACRC,SAAS,QAATA,SAAS;EAET,IAAMC,QAAQ,GAAGC,UAAU,CAACC,oBAAoB,CAAC;EACjD,IAAMC,UAAU,GAAGF,UAAU,CAACG,eAAe,CAAC,IAAI,IAAI;EACtD,IAAMC,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;EAC9C,IAAI,CAACH,UAAU,IAAI,CAACE,QAAQ,EAAE;IAC5B,MAAM,IAAIE,KAAK,CACb,iFAAiF,CAClF;;EAEH,OACEC,oBAACC,QAAQ;IACPb,QAAQ,EAAEA,QAAQ,IAAKI,QAAQ,IAAI,CAACH,eAAgB;IACpDF,KAAK,EAAEA,KAAK;IACZI,SAAS,EAAEA;KAEVD,QAAQ,CACA;AAEf;AAEA;;;;;;;IAOaY,8BAA8B,GACzC;EACEC,IAAI,EAAE,0BAA0B;EAChCC,WAAW,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MACVnC,IAAI,EAAE,QAAQ;MACdK,WAAW,EAAE,uDAAuD;MACpE+B,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;MACnCxC,WAAW,EAAE;;;CAGlB;AAED;;;AAGA,SAAgByC,wBAAwB,CACtC7B,MAAwD,EACxD8B,0BAAiE;EAEjE,IAAI9B,MAAM,EAAE;IACVA,MAAM,CAACE,iBAAiB,CACtBmB,uBAAuB,EACvBS,0BAA0B,WAA1BA,0BAA0B,GAAIP,oBAAoB,CACnD;GACF,MAAM;IACLrB,iBAAiB,CACfmB,uBAAuB,EACvBS,0BAA0B,WAA1BA,0BAA0B,GAAIP,oBAAoB,CACnD;;AAEL;AAEA,IAAaQ,0BAA0B,GACrC;EACE5C,IAAI,EAAE,0BAA0B;EAChCC,WAAW,EAAE,mBAAmB;EAChCC,UAAU,EAAE,yBAAyB;EACrCC,UAAU,EAAE,oCAAoC;EAChDC,KAAK,EAAE;IACLoC,UAAU,EAAE;MACVnC,IAAI,EAAE,QAAQ;MACdK,WAAW,EAAE,uDAAuD;MACpE+B,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;MACnCxC,WAAW,EAAE;;;CAGlB;AAEH,SAAgB4C,8BAA8B,CAC5ChC,MAAgE,EAChE8B,0BAAqE;EAErE,IAAI9B,MAAM,EAAE;IACVA,MAAM,CAACiC,qBAAqB,CAC1BZ,uBAAuB,EACvBS,0BAA0B,WAA1BA,0BAA0B,GAAIC,0BAA0B,CACzD;GACF,MAAM;IACLE,qBAAqB,CACnBZ,uBAAuB,EACvBS,0BAA0B,WAA1BA,0BAA0B,GAAIC,0BAA0B,CACzD;;AAEL;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/react-scroll-parallax",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.98",
|
|
4
4
|
"description": "Plasmic registration call for the HTML5 video element",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"analyze": "size-limit --why"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@plasmicapp/host": "1.0.
|
|
31
|
+
"@plasmicapp/host": "1.0.93",
|
|
32
32
|
"@size-limit/preset-small-lib": "^4.11.0",
|
|
33
33
|
"@types/node": "^14.0.26",
|
|
34
34
|
"size-limit": "^4.11.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"react": ">=16.8.0",
|
|
46
46
|
"react-dom": ">=16.8.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "e282c9cca3a168a822b34a1a5e6de3a6a072c00f"
|
|
49
49
|
}
|