{"version":3,"file":"ProjectsGridJump.D2rCmLDQ.mjs","names":["useRef","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","c","init_jsx_runtime","ce","de","init_framer_DKgW_P28","addPropertyControls","ControlType","useIsStaticRenderer","readRequest","raw","STORAGE_KEY","pinnedHeaderHeight","nav","pos","ProjectsGridJump","props","ref","isStatic","mode","link","el","i","remember","target","timers","raf","cancelled","targetTop","offset","stop","listen","cleanup","t","request","name","MAX_AGE_MS","jump","autoScroll","autoDelay","init_ProjectsGridJump","p"],"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":"A,uMAa8M,SAASa,GAAa,CAAC,GAAG,CAAC,IAAMC,EAAIV,EAAO,eAAe,QAAQW,C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