@plasmicpkgs/react-scroll-parallax 0.0.214 → 0.0.216

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.
@@ -120,6 +120,19 @@ function registerParallaxWrapper(loader, customParallaxWrapperMeta) {
120
120
  }
121
121
 
122
122
  var _excluded = ["children"];
123
+ /**
124
+ * A safe wrapper around `useController()` to prevent errors when
125
+ * `ParallaxProvider` is missing. If the context is unavailable,
126
+ * `useController()` will throw an error, which we catch and handle
127
+ * gracefully by returning `null` instead of crashing the component.
128
+ */
129
+ function useSafeController() {
130
+ try {
131
+ return reactScrollParallax.useController();
132
+ } catch (_unused) {
133
+ return null; // Return null instead of throwing an error
134
+ }
135
+ }
123
136
  /**
124
137
  * This is required to ensure the parallax scrolling works correctly, since if
125
138
  * (for instance) images load after the parallax wrapper has calculated the
@@ -132,7 +145,7 @@ var _excluded = ["children"];
132
145
  */
133
146
  function ParallaxCacheUpdate(_ref) {
134
147
  var children = _ref.children;
135
- var parallaxController = reactScrollParallax.useController();
148
+ var parallaxController = useSafeController();
136
149
  var ref = React.useRef(null);
137
150
  React.useEffect(function () {
138
151
  var _ref$current;
@@ -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 styles: {\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","_ref","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","styles","maxWidth","description","defaultStyles","deprecated_registerParallaxWrapper","loader","customParallaxWrapperMeta","registerComponent","parallaxWrapperMeta","_extends","isAttachment","registerParallaxWrapper","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","_ref$current","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","style","display","ParallaxProviderWrapper","_ref2","_objectWithoutPropertiesLoose","_excluded","ParallaxProvider","parallaxProviderMeta","value","marginBottom","scrollAxis","options","registerParallaxProvider","customParallaxProviderMeta","globalParallaxProviderMeta","registerGlobalParallaxProvider","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAewBA,eAAeA,CAAAC,IAAA;MACrCC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACRC,SAAS,GAAAL,IAAA,CAATK,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;;;;;;;IAO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;;"}
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 styles: {\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 * A safe wrapper around `useController()` to prevent errors when\n * `ParallaxProvider` is missing. If the context is unavailable,\n * `useController()` will throw an error, which we catch and handle\n * gracefully by returning `null` instead of crashing the component.\n */\nfunction useSafeController() {\n try {\n return useController();\n } catch {\n return null; // Return null instead of throwing an error\n }\n}\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 = useSafeController();\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","_ref","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","styles","maxWidth","description","defaultStyles","deprecated_registerParallaxWrapper","loader","customParallaxWrapperMeta","registerComponent","parallaxWrapperMeta","_extends","isAttachment","registerParallaxWrapper","useSafeController","useController","_unused","ParallaxCacheUpdate","parallaxController","ref","useRef","useEffect","_ref$current","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","style","display","ParallaxProviderWrapper","_ref2","_objectWithoutPropertiesLoose","_excluded","ParallaxProvider","parallaxProviderMeta","value","marginBottom","scrollAxis","options","registerParallaxProvider","customParallaxProviderMeta","globalParallaxProviderMeta","registerGlobalParallaxProvider","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;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E,IAAIrC,MAAM,EAAE;IACVA,MAAM,CAACE,iBAAiB,CACtBwB,uBAAuB,EACvBW,0BAA0B,WAA1BA,0BAA0B,GAAIN,oBAAoB,CACnD;GACF,MAAM;IACL7B,iBAAiB,CACfwB,uBAAuB,EACvBW,0BAA0B,WAA1BA,0BAA0B,GAAIN,oBAAoB,CACnD;;AAEL;AAEA,IAAaO,0BAA0B,GACrC;EACEnD,IAAI,EAAE,0BAA0B;EAChCC,WAAW,EAAE,mBAAmB;EAChCC,UAAU,EAAE,yBAAyB;EACrCC,UAAU,EAAE,oCAAoC;EAChDC,KAAK,EAAE;IACL2C,UAAU,EAAE;MACV1C,IAAI,EAAE,QAAQ;MACdK,WAAW,EAAE,uDAAuD;MACpEsC,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;MACnC/C,WAAW,EAAE;;;CAGlB;AAEH,SAAgBmD,8BAA8BA,CAC5CvC,MAAgE,EAChEqC,0BAAqE;EAErE,IAAIrC,MAAM,EAAE;IACVA,MAAM,CAACwC,qBAAqB,CAC1Bd,uBAAuB,EACvBW,0BAA0B,WAA1BA,0BAA0B,GAAIC,0BAA0B,CACzD;GACF,MAAM;IACLE,qBAAqB,CACnBd,uBAAuB,EACvBW,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?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",styles:{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)};
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),u=null!=l.useContext(o.ParallaxContext),d="undefined"==typeof window;if(!u&&!d)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",styles:{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%"}},u=s({},c,{isAttachment:!0}),d=["children"];function x(e){var r=e.children,a=function(){try{return o.useController()}catch(e){return null}}(),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,d);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=u,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:u):a(p,null!=r?r:u)};
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 styles: {\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","_ref","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","styles","maxWidth","description","defaultStyles","parallaxWrapperMeta","_extends","isAttachment","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","_ref$current","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","style","display","ParallaxProviderWrapper","_ref2","_objectWithoutPropertiesLoose","_excluded","ParallaxProvider","parallaxProviderMeta","value","marginBottom","scrollAxis","options","globalParallaxProviderMeta","loader","customParallaxWrapperMeta","registerComponent","customParallaxProviderMeta","registerGlobal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,CACxErC,KAAM,6BACNC,YAAa,oBACbC,WAAY,0BACZC,WAAY,qCACZC,MAAO,CACLjB,SAAU,CACRkB,KAAM,OACNC,aAAc,CACZD,KAAM,OACNlB,SAAU,CACR,CACEkB,KAAM,OACNiC,MACE,8GACF9B,OAAQ,CACN+B,aAAc,SAGlB,CACElC,KAAM,YACNL,KAAM,+BAKdwC,WAAY,CACVnC,KAAM,SACNK,YAAa,wDACb+B,QAAS,CAAC,WAAY,cACtBxC,YAAa,iBAyBNyC,EACX,CACE1C,KAAM,2BACNC,YAAa,oBACbC,WAAY,0BACZC,WAAY,qCACZC,MAAO,CACLoC,WAAY,CACVnC,KAAM,SACNK,YAAa,wDACb+B,QAAS,CAAC,WAAY,cACtBxC,YAAa,0KD1CnB0C,EACAC,GAEID,EACFA,EAAOE,kBACL/D,QACA8D,EAAAA,EAA6B7C,GAG/B8C,EACE/D,QACA8D,EAAAA,EAA6B7C,sJCqCjC4C,EACAG,GAEIH,EACFA,EAAOI,sBACLf,QACAc,EAAAA,EAA8BJ,GAGhCK,EACEf,QACAc,EAAAA,EAA8BJ,8CA5ClCC,EACAG,GAEIH,EACFA,EAAOE,kBACLb,QACAc,EAAAA,EAA8BT,GAGhCQ,EACEb,QACAc,EAAAA,EAA8BT,6CDDlCM,EACAC,GAEID,EACFA,EAAOE,kBACL/D,QACA8D,EAAAA,EAA6BhC,GAG/BiC,EACE/D,QACA8D,EAAAA,EAA6BhC"}
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 styles: {\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 * A safe wrapper around `useController()` to prevent errors when\n * `ParallaxProvider` is missing. If the context is unavailable,\n * `useController()` will throw an error, which we catch and handle\n * gracefully by returning `null` instead of crashing the component.\n */\nfunction useSafeController() {\n try {\n return useController();\n } catch {\n return null; // Return null instead of throwing an error\n }\n}\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 = useSafeController();\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","_ref","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","styles","maxWidth","description","defaultStyles","parallaxWrapperMeta","_extends","isAttachment","ParallaxCacheUpdate","parallaxController","useController","_unused","useSafeController","ref","useRef","useEffect","_ref$current","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","style","display","ParallaxProviderWrapper","_ref2","_objectWithoutPropertiesLoose","_excluded","ParallaxProvider","parallaxProviderMeta","value","marginBottom","scrollAxis","options","globalParallaxProviderMeta","loader","customParallaxWrapperMeta","registerComponent","customParallaxProviderMeta","registerGlobalContext"],"mappings":"wmBAewBA,EAAeC,OACrCC,EAAKD,EAALC,MACAC,EAAQF,EAARE,SACAC,EAAeH,EAAfG,gBACAC,EAAQJ,EAARI,SACAC,EAASL,EAATK,UAEMC,EAAWC,aAAWC,wBACtBC,EAA4C,MAA/BF,aAAWG,mBACxBC,EAA6B,oBAAXC,OACxB,IAAKH,IAAeE,EAClB,MAAM,IAAIE,MACR,mFAGJ,OACEC,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,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WAAY,CACVrC,KAAM,SACNK,YAAa,wDACbiC,QAAS,CAAC,WAAY,cACtB1C,YAAa,0KDxDnB4C,EACAC,GAEID,EACFA,EAAOE,kBACLjE,QACAgE,EAAAA,EAA6B/C,GAG/BgD,EACEjE,QACAgE,EAAAA,EAA6B/C,sJCmDjC8C,EACAG,GAEIH,EACFA,EAAOI,sBACLf,QACAc,EAAAA,EAA8BJ,GAGhCK,EACEf,QACAc,EAAAA,EAA8BJ,8CA5ClCC,EACAG,GAEIH,EACFA,EAAOE,kBACLb,QACAc,EAAAA,EAA8BT,GAGhCQ,EACEb,QACAc,EAAAA,EAA8BT,6CDflCM,EACAC,GAEID,EACFA,EAAOE,kBACLjE,QACAgE,EAAAA,EAA6BlC,GAG/BmC,EACEjE,QACAgE,EAAAA,EAA6BlC"}
@@ -113,6 +113,19 @@ function registerParallaxWrapper(loader, customParallaxWrapperMeta) {
113
113
  }
114
114
 
115
115
  var _excluded = ["children"];
116
+ /**
117
+ * A safe wrapper around `useController()` to prevent errors when
118
+ * `ParallaxProvider` is missing. If the context is unavailable,
119
+ * `useController()` will throw an error, which we catch and handle
120
+ * gracefully by returning `null` instead of crashing the component.
121
+ */
122
+ function useSafeController() {
123
+ try {
124
+ return useController();
125
+ } catch (_unused) {
126
+ return null; // Return null instead of throwing an error
127
+ }
128
+ }
116
129
  /**
117
130
  * This is required to ensure the parallax scrolling works correctly, since if
118
131
  * (for instance) images load after the parallax wrapper has calculated the
@@ -125,7 +138,7 @@ var _excluded = ["children"];
125
138
  */
126
139
  function ParallaxCacheUpdate(_ref) {
127
140
  var children = _ref.children;
128
- var parallaxController = useController();
141
+ var parallaxController = useSafeController();
129
142
  var ref = useRef(null);
130
143
  useEffect(function () {
131
144
  var _ref$current;
@@ -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 styles: {\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","_ref","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","styles","maxWidth","description","defaultStyles","deprecated_registerParallaxWrapper","loader","customParallaxWrapperMeta","registerComponent","parallaxWrapperMeta","_extends","isAttachment","registerParallaxWrapper","ParallaxCacheUpdate","parallaxController","useController","ref","useRef","useEffect","_ref$current","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","style","display","ParallaxProviderWrapper","_ref2","_objectWithoutPropertiesLoose","_excluded","ParallaxProvider","parallaxProviderMeta","value","marginBottom","scrollAxis","options","registerParallaxProvider","customParallaxProviderMeta","globalParallaxProviderMeta","registerGlobalParallaxProvider","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAewBA,eAAeA,CAAAC,IAAA;MACrCC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACRC,SAAS,GAAAL,IAAA,CAATK,SAAS;EAET,IAAMC,QAAQ,GAAGC,UAAU,CAACC,oBAAoB,CAAC;EACjD,IAAMC,UAAU,GAAGF,UAAU,CAACG,eAAe,CAAC,IA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AAC;MACnC7C,WAAW,EAAE;;;CAGlB;AAEH,SAAgBiD,8BAA8BA,CAC5CrC,MAAgE,EAChEmC,0BAAqE;EAErE,IAAInC,MAAM,EAAE;IACVA,MAAM,CAACsC,qBAAqB,CAC1Bd,uBAAuB,EACvBW,0BAA0B,WAA1BA,0BAA0B,GAAIC,0BAA0B,CACzD;GACF,MAAM;IACLE,qBAAqB,CACnBd,uBAAuB,EACvBW,0BAA0B,WAA1BA,0BAA0B,GAAIC,0BAA0B,CACzD;;AAEL;;;;"}
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 styles: {\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 * A safe wrapper around `useController()` to prevent errors when\n * `ParallaxProvider` is missing. If the context is unavailable,\n * `useController()` will throw an error, which we catch and handle\n * gracefully by returning `null` instead of crashing the component.\n */\nfunction useSafeController() {\n try {\n return useController();\n } catch {\n return null; // Return null instead of throwing an error\n }\n}\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 = useSafeController();\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","_ref","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","styles","maxWidth","description","defaultStyles","deprecated_registerParallaxWrapper","loader","customParallaxWrapperMeta","registerComponent","parallaxWrapperMeta","_extends","isAttachment","registerParallaxWrapper","useSafeController","useController","_unused","ParallaxCacheUpdate","parallaxController","ref","useRef","useEffect","_ref$current","current","parentElement","targetNode","observer","ResizeObserver","update","observe","disconnect","style","display","ParallaxProviderWrapper","_ref2","_objectWithoutPropertiesLoose","_excluded","ParallaxProvider","parallaxProviderMeta","value","marginBottom","scrollAxis","options","registerParallaxProvider","customParallaxProviderMeta","globalParallaxProviderMeta","registerGlobalParallaxProvider","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAewBA,eAAeA,CAAAC,IAAA;MACrCC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACRC,SAAS,GAAAL,IAAA,CAATK,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,EAAE,iBAAiB;EAC9BC,UAAU,EAAE,iBAAiB;EAC7BC,UAAU,EAAE,oCAAoC;EAChDC,KAAK,EAAE;IACLjB,QAAQ,EAAE;MACRkB,IAAI,EAAE,MAAM;MACZC,YAAY,EAAE;QACZD,IAAI,EAAE,KAA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"version": "0.0.216",
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.207",
31
+ "@plasmicapp/host": "1.0.208",
32
32
  "@size-limit/preset-small-lib": "^4.11.0",
33
33
  "@types/node": "^14.0.26",
34
34
  "@types/react": "^18.2.33",
@@ -45,5 +45,5 @@
45
45
  "react": ">=16.8.0",
46
46
  "react-dom": ">=16.8.0"
47
47
  },
48
- "gitHead": "9097835f7f37064c7aeefbdcdbf7d2ba0ca652c9"
48
+ "gitHead": "73b93827039fd8689edbca25f0594e9cbba04cbe"
49
49
  }