{"version":3,"file":"ProjectsGridJump.z-hV19Bz.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/ERY8fBi63qLIlM176MyH/NwwCfRZ9zVGgwH506bO3/ProjectsGridJump.js"],"sourcesContent":["// User request: The Next / Previous buttons on all 3 Projects pages should show the\n// project grid of the page they open, instead of landing on the hero section.\n// User request (update): \"Back to All Services\" text links also land on the services grid.\n// User request (update): on the main Projects page, show the hero briefly and then\n// scroll down to the project cards automatically (main page only for now).\n//\n// How it works (invisible helper, two modes):\n// - \"Grid Target\": one instance at the top of each page's project-grid section.\n//   Optional \"Auto Scroll\": after the delay, smoothly scrolls to the grid on every visit.\n// - \"Button\": one instance inside each Next / Previous / Back to Start button.\n// Clicking a button remembers the request for a few seconds; when the next page\n// loads, its Grid Target jumps straight to the grid (below the header if the header\n// stays visible). Visitors who scroll, tap or press a key cancel the auto scroll.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";const STORAGE_KEY=\"hcc-grid-jump\";const MAX_AGE_MS=1e4;function readRequest(){try{const raw=window.sessionStorage.getItem(STORAGE_KEY);return raw?JSON.parse(raw):null;}catch{return null;}}// Height of a header that stays pinned at the top while scrolling down.\n// A header that auto-hides on scroll (AutoHideNav) doesn't need clearance.\nfunction pinnedHeaderHeight(){const nav=document.querySelector('[data-framer-name=\"Navigation\"]');if(!nav)return 0;const autoHides=nav.style.willChange===\"transform\";if(autoHides)return 0;const pos=window.getComputedStyle(nav).position;if(pos!==\"sticky\"&&pos!==\"fixed\")return 0;return nav.getBoundingClientRect().height;}/**\n * Projects Grid Jump\n *\n * @framerIntrinsicWidth 1\n * @framerIntrinsicHeight 1\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function ProjectsGridJump(props){const{mode,name,offset,autoScroll,autoDelay}=props;const ref=useRef(null);const isStatic=useIsStaticRenderer();useEffect(()=>{if(isStatic||!ref.current||typeof window===\"undefined\")return;if(mode===\"button\"){// The helper sits inside the button, or next to a text link: find the nearest link\nlet link=ref.current.closest(\"a\");let el=ref.current;for(let i=0;!link&&el&&i<5;i++){el=el.parentElement;link=el?el.querySelector(\"a\"):null;}if(!link)return;const remember=()=>{try{window.sessionStorage.setItem(STORAGE_KEY,JSON.stringify({name,t:Date.now()}));}catch{// Storage unavailable: the button just behaves like a normal link\n}};const target=link;target.addEventListener(\"click\",remember,true);return()=>target.removeEventListener(\"click\",remember,true);}// Grid Target\nconst el=ref.current;const timers=[];let raf=0;let cancelled=false;const targetTop=()=>el.getBoundingClientRect().top+window.scrollY-pinnedHeaderHeight()-offset;const stop=()=>{cancelled=true;};const listen=()=>{window.addEventListener(\"wheel\",stop,{passive:true});window.addEventListener(\"touchstart\",stop,{passive:true});window.addEventListener(\"keydown\",stop);};const cleanup=()=>{cancelled=true;window.cancelAnimationFrame(raf);timers.forEach(t=>window.clearTimeout(t));window.removeEventListener(\"wheel\",stop);window.removeEventListener(\"touchstart\",stop);window.removeEventListener(\"keydown\",stop);};const request=readRequest();const requested=!!request&&request.name===name&&Date.now()-request.t<=MAX_AGE_MS;if(requested){try{window.sessionStorage.removeItem(STORAGE_KEY);}catch{// ignore\n}// Instant jump, repeated briefly so the page's own scroll-to-top can't undo it\nconst jump=()=>{if(cancelled)return;window.scrollTo({top:Math.max(0,targetTop()),behavior:\"instant\"});};jump();raf=window.requestAnimationFrame(jump);timers.push(window.setTimeout(jump,80),window.setTimeout(jump,250));timers.push(window.setTimeout(stop,300));listen();return cleanup;}if(autoScroll){const reduce=!!window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;if(reduce)return;listen();timers.push(window.setTimeout(()=>{// Skip if the visitor already moved down the page or interacted\nif(cancelled||window.scrollY>40)return;window.scrollTo({top:Math.max(0,targetTop()),behavior:\"smooth\"});},Math.max(0,autoDelay)*1e3));return cleanup;}return cleanup;},[mode,name,offset,autoScroll,autoDelay,isStatic]);return /*#__PURE__*/_jsx(\"span\",{ref:ref,\"aria-hidden\":\"true\",style:{...props.style,display:\"block\",width:\"100%\",height:\"100%\",pointerEvents:\"none\"}});}addPropertyControls(ProjectsGridJump,{mode:{type:ControlType.Enum,title:\"Mode\",options:[\"target\",\"button\"],optionTitles:[\"Grid Target\",\"Button\"],defaultValue:\"target\",displaySegmentedControl:true},name:{type:ControlType.String,title:\"Name\",defaultValue:\"projects-grid\",description:\"Buttons scroll to the Grid Target with the same name on the page they open.\"},offset:{type:ControlType.Number,title:\"Extra Offset\",defaultValue:0,min:-200,max:200,unit:\"px\",hidden:p=>p.mode!==\"target\"},autoScroll:{type:ControlType.Boolean,title:\"Auto Scroll\",defaultValue:false,description:\"Scroll to the grid automatically after the delay on every visit.\",hidden:p=>p.mode!==\"target\"},autoDelay:{type:ControlType.Number,title:\"Delay\",defaultValue:1.5,min:0,max:10,step:.1,unit:\"s\",hidden:p=>p.mode!==\"target\"||!p.autoScroll}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProjectsGridJump\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicHeight\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProjectsGridJump.map"],"mappings":"uMAa8M,SAAS,GAAa,CAAC,GAAG,CAAC,IAAM,EAAI,EAAO,eAAe,QAAQ,CAAW,EAAE,OAAO,EAAI,KAAK,MAAM,CAAG,EAAE,IAAK,MAAM,CAAC,OAAO,IAAK,CAAC,CAElV,SAAS,GAAoB,CAAC,IAAM,EAAI,SAAS,cAAc,iCAAiC,EAAsE,GAAjE,CAAC,GAA6B,EAAI,MAAM,aAAa,YAAyB,MAAO,GAAE,IAAM,EAAI,EAAO,iBAAiB,CAAG,CAAC,CAAC,SAAmD,OAAvC,IAAM,UAAU,IAAM,QAAe,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