{"version":3,"file":"PinnedTabletScroll.CC7i0VWM.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/GiAJWmFtucpASokMX8Fb/sG7sMyEEWBO9E1YDZBiE/PinnedTabletScroll.js"],"sourcesContent":["// Pinned section that scrolls an image vertically inside a tablet mockup\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useScroll,useTransform,motion}from\"framer-motion\";import{useRef,useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function PinnedTabletScroll(props){const{image={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Scrolling content\"},deviceType,tabletOrientation,tabletColor,screenBorderRadius,bezelSize,additionalOffset,browserUrl}=props;const containerRef=useRef(null);const imageRef=useRef(null);const screenRef=useRef(null);const[imageHeight,setImageHeight]=useState(0);const[viewportHeight,setViewportHeight]=useState(0);const[screenHeight,setScreenHeight]=useState(0);const[isSmallScreen,setIsSmallScreen]=useState(false);useEffect(()=>{const updateDimensions=()=>{if(imageRef.current){startTransition(()=>{setImageHeight(imageRef.current.offsetHeight);setViewportHeight(window.innerHeight);if(screenRef.current){setScreenHeight(screenRef.current.offsetHeight);}setIsSmallScreen(window.innerWidth<400);});}};const img=imageRef.current;if(img){if(img.complete){updateDimensions();}else{img.addEventListener(\"load\",updateDimensions);}}window.addEventListener(\"resize\",updateDimensions);return()=>{if(img){img.removeEventListener(\"load\",updateDimensions);}window.removeEventListener(\"resize\",updateDimensions);};},[image.src]);// Calculate the mockup screen height (80vh max)\nconst mockupScreenHeight=Math.min(viewportHeight*.8,viewportHeight*.8);// Calculate the actual visible screen height (subtract browser bar if shown)\nconst browserBarHeight=props.showBrowserButtons?40:0;const visibleScreenHeight=screenHeight>0?screenHeight-browserBarHeight:mockupScreenHeight-bezelSize*2-browserBarHeight;// Calculate how much the image needs to scroll\n// The image should scroll until its bottom is visible in the mockup\nconst scrollAmount=imageHeight>visibleScreenHeight?imageHeight-visibleScreenHeight:0;// Container height = scroll amount + viewport height + additional offset\n// This ensures the section stays pinned for the full scroll duration\nconst containerHeight=scrollAmount+viewportHeight+additionalOffset;const{scrollYProgress}=useScroll({target:containerRef,offset:[\"start start\",\"end end\"]});const imageY=useTransform(scrollYProgress,[0,1],[0,-scrollAmount]);const isMobile=deviceType===\"mobile\";const isPortrait=tabletOrientation===\"portrait\";const mobileWidth=isMobile&&isSmallScreen?\"80%\":\"400px\";return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{width:\"100%\",height:`${containerHeight}px`,position:\"relative\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"sticky\",top:0,width:\"100%\",height:\"100vh\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",zIndex:10},children:/*#__PURE__*/_jsxs(\"div\",{style:{width:isMobile?mobileWidth:\"auto\",maxWidth:isMobile?\"550px\":\"none\",height:isMobile?\"auto\":\"auto\",maxHeight:isMobile?\"none\":\"80vh\",aspectRatio:isMobile?\"9 / 16\":isPortrait?\"3 / 4\":\"4 / 3\",backgroundColor:tabletColor,borderRadius:screenBorderRadius+bezelSize,padding:bezelSize,boxShadow:\"0 20px 60px rgba(0, 0, 0, 0.3)\",position:\"relative\"},children:[props.showBrowserButtons&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"absolute\",top:bezelSize,left:bezelSize,right:bezelSize,height:40,backgroundColor:\"#f6f6f6\",borderTopLeftRadius:screenBorderRadius,borderTopRightRadius:screenBorderRadius,display:\"flex\",alignItems:\"center\",padding:\"0 12px\",gap:12,zIndex:1},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",gap:8},children:[/*#__PURE__*/_jsx(\"div\",{style:{width:12,height:12,borderRadius:\"50%\",backgroundColor:\"#FF5F56\"}}),/*#__PURE__*/_jsx(\"div\",{style:{width:12,height:12,borderRadius:\"50%\",backgroundColor:\"#FFBD2E\"}}),/*#__PURE__*/_jsx(\"div\",{style:{width:12,height:12,borderRadius:\"50%\",backgroundColor:\"#27C93F\"}})]}),/*#__PURE__*/_jsx(\"div\",{style:{flex:1,height:24,backgroundColor:\"#fff\",borderRadius:6,display:\"flex\",alignItems:\"center\",padding:\"0 10px\",fontSize:12,color:\"#666\",overflow:\"hidden\",textOverflow:\"ellipsis\",whiteSpace:\"nowrap\"},children:browserUrl})]}),/*#__PURE__*/_jsx(\"div\",{ref:screenRef,style:{width:\"100%\",height:\"100%\",borderRadius:screenBorderRadius,overflow:\"hidden\",position:\"relative\",backgroundColor:\"#000\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",overflow:\"hidden\",position:\"relative\"},children:/*#__PURE__*/_jsx(motion.img,{ref:imageRef,src:image.src,alt:image.alt,style:{width:\"100%\",height:\"auto\",display:\"block\",y:imageY,marginTop:props.showBrowserButtons?40:0}})})})]})}),/*#__PURE__*/_jsx(\"div\",{style:{height:`${scrollAmount+additionalOffset}px`,pointerEvents:\"none\"}})]});}addPropertyControls(PinnedTabletScroll,{deviceType:{type:ControlType.Enum,title:\"Device Type\",options:[\"tablet\",\"mobile\"],optionTitles:[\"Tablet\",\"Mobile\"],defaultValue:\"tablet\",displaySegmentedControl:true},tabletOrientation:{type:ControlType.Enum,title:\"Orientation\",options:[\"landscape\",\"portrait\"],optionTitles:[\"Landscape\",\"Portrait\"],defaultValue:\"landscape\",displaySegmentedControl:true,hidden:({deviceType})=>deviceType===\"mobile\"},image:{type:ControlType.ResponsiveImage,title:\"Image\"},showBrowserButtons:{type:ControlType.Boolean,title:\"Browser Bar\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},browserUrl:{type:ControlType.String,title:\"URL\",defaultValue:\"https://www.example.com\",hidden:({showBrowserButtons})=>!showBrowserButtons},tabletColor:{type:ControlType.Color,title:\"Tablet Color\",defaultValue:\"#1a1a1a\"},screenBorderRadius:{type:ControlType.Number,title:\"Screen Radius\",defaultValue:12,min:0,max:40,step:1,unit:\"px\"},bezelSize:{type:ControlType.Number,title:\"Bezel Size\",defaultValue:20,min:0,max:60,step:1,unit:\"px\"},additionalOffset:{type:ControlType.Number,title:\"Additional Offset\",defaultValue:0,min:0,max:2e3,step:50,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PinnedTabletScroll\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PinnedTabletScroll.map"],"mappings":"gRAIG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,IAAI,sEAAsE,IAAI,oBAAoB,CAAC,aAAW,oBAAkB,cAAY,qBAAmB,YAAU,mBAAiB,cAAY,EAAY,EAAaA,EAAO,KAAK,CAAO,EAASA,EAAO,KAAK,CAAO,EAAUA,EAAO,KAAK,CAAM,CAAC,EAAY,GAAgBC,EAAS,EAAE,CAAM,CAAC,EAAe,GAAmBA,EAAS,EAAE,CAAM,CAAC,EAAa,GAAiBA,EAAS,EAAE,CAAM,CAAC,EAAc,GAAkBA,EAAS,GAAM,CAAC,MAAc,CAAC,IAAM,MAAqB,CAAI,EAAS,SAAS,MAAoB,CAAC,EAAe,EAAS,QAAQ,aAAa,CAAC,EAAkB,EAAO,YAAY,CAAI,EAAU,SAAS,EAAgB,EAAU,QAAQ,aAAa,CAAE,EAAiB,EAAO,WAAW,IAAI,EAAG,EAAU,EAAI,EAAS,QAA6J,OAAlJ,IAAQ,EAAI,SAAU,GAAkB,CAAO,EAAI,iBAAiB,OAAO,EAAiB,EAAG,EAAO,iBAAiB,SAAS,EAAiB,KAAW,CAAI,GAAK,EAAI,oBAAoB,OAAO,EAAiB,CAAE,EAAO,oBAAoB,SAAS,EAAiB,GAAK,CAAC,EAAM,IAAI,CAAC,C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