{"version":3,"file":"Scroll_Progress_Bar.BnZaRPEV.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/qGxcI8iqSo4Pu9ZVuXEu/mgFTAYhCCroDtPQ0a18q/Scroll_Progress_Bar.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion}from\"framer-motion\";/**\n * Scroll Progress Bar\n * A customizable progress bar that tracks scroll progress of a section or entire page\n *\n * @framerDisableUnlink\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 8\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight fixed\n */export default function ScrollSectionNav(props){const{trackingMode,sectionName,direction,backgroundColor,fillColor,style}=props;const[scrollProgress,setScrollProgress]=useState(0);const scrollElementRef=useRef(null);// Determine if reversed based on direction\nconst isReversed=direction===\"right\";useEffect(()=>{if(typeof window===\"undefined\")return;if(RenderTarget.current()===RenderTarget.canvas)return;let cleanup=()=>{};if(trackingMode===\"page\"){// Page scroll tracking\nconst handlePageScroll=()=>{const scrollTop=window.pageYOffset||document.documentElement.scrollTop;const scrollHeight=document.documentElement.scrollHeight;const clientHeight=document.documentElement.clientHeight;const maxScroll=scrollHeight-clientHeight;let progress=0;if(maxScroll>0){progress=scrollTop/maxScroll;}if(isReversed){progress=1-progress;}setScrollProgress(Math.min(1,Math.max(0,progress)));};window.addEventListener(\"scroll\",handlePageScroll,{passive:true});window.addEventListener(\"resize\",handlePageScroll);handlePageScroll();cleanup=()=>{window.removeEventListener(\"scroll\",handlePageScroll);window.removeEventListener(\"resize\",handlePageScroll);};}else if(trackingMode===\"section\"&&sectionName){// Section scroll tracking\nconst findAndTrackSection=()=>{// Clean the section name - don't modify it, use as-is first\nconst originalName=sectionName.trim();// Also prepare variations\nconst nameWithHash=originalName.startsWith(\"#\")?originalName:\"#\"+originalName;const nameWithoutHash=originalName.startsWith(\"#\")?originalName.substring(1):originalName;const lowerCaseName=originalName.toLowerCase();const lowerCaseWithHash=nameWithHash.toLowerCase();const lowerCaseWithoutHash=nameWithoutHash.toLowerCase();console.log(`Looking for section: \"${originalName}\"`);// Try to find the section with various methods\nlet targetElement=null;// Method 1: Direct data-framer-name match (exact)\ntargetElement=document.querySelector(`[data-framer-name=\"${originalName}\"]`)||document.querySelector(`[data-framer-name=\"${nameWithHash}\"]`)||document.querySelector(`[data-framer-name=\"${nameWithoutHash}\"]`);// Method 2: Case-insensitive search\nif(!targetElement){const allElements=document.querySelectorAll(\"[data-framer-name]\");targetElement=Array.from(allElements).find(el=>{const name=el.getAttribute(\"data-framer-name\")?.toLowerCase();return name===lowerCaseName||name===lowerCaseWithHash||name===lowerCaseWithoutHash;})||null;}// Method 3: Look for Framer's scroll containers\nif(!targetElement){// Framer often wraps scroll sections in containers\n// Look for elements with specific Framer classes or attributes\nconst scrollContainers=document.querySelectorAll('[data-framer-component-type=\"ScrollSection\"], [data-framer-scroll-section], .framer-scroll-section');for(const container of scrollContainers){// Check if this container or its children have our target name\nconst hasName=container.getAttribute(\"data-framer-name\")===originalName||container.querySelector(`[data-framer-name=\"${originalName}\"]`);if(hasName){targetElement=container;break;}}}if(!targetElement){console.error(`Section \"${originalName}\" not found`);console.log(\"Available sections:\");document.querySelectorAll(\"[data-framer-name]\").forEach(el=>{console.log(`- \"${el.getAttribute(\"data-framer-name\")}\"`);});return null;}console.log(\"Found section element:\",targetElement);// Now find the actual scrollable element\n// It could be the element itself or a child/parent\nlet scrollElement=null;// Check if the target element itself is scrollable\nconst checkScrollable=el=>{const style=window.getComputedStyle(el);const hasScrollX=(style.overflowX===\"auto\"||style.overflowX===\"scroll\")&&el.scrollWidth>el.clientWidth;const hasScrollY=(style.overflowY===\"auto\"||style.overflowY===\"scroll\")&&el.scrollHeight>el.clientHeight;return hasScrollX||hasScrollY;};if(checkScrollable(targetElement)){scrollElement=targetElement;}else{// Check children\nconst scrollableChild=targetElement.querySelector(\"*\");if(scrollableChild&&checkScrollable(scrollableChild)){scrollElement=scrollableChild;}else{// Check parent\nlet parent=targetElement.parentElement;while(parent&&parent!==document.body){if(checkScrollable(parent)){scrollElement=parent;break;}parent=parent.parentElement;}}}// Last resort: find any scrollable element within or around the target\nif(!scrollElement){const allDescendants=targetElement.querySelectorAll(\"*\");for(const el of allDescendants){if(checkScrollable(el)){scrollElement=el;break;}}}if(!scrollElement){console.error(\"No scrollable element found in section\");return null;}console.log(\"Scrollable element found:\",scrollElement);scrollElementRef.current=scrollElement;// Set up scroll tracking\nconst handleScroll=()=>{if(!scrollElement)return;let progress=0;const style=window.getComputedStyle(scrollElement);const hasScrollX=(style.overflowX===\"auto\"||style.overflowX===\"scroll\")&&scrollElement.scrollWidth>scrollElement.clientWidth;const hasScrollY=(style.overflowY===\"auto\"||style.overflowY===\"scroll\")&&scrollElement.scrollHeight>scrollElement.clientHeight;if(hasScrollX){const maxScroll=scrollElement.scrollWidth-scrollElement.clientWidth;if(maxScroll>0){progress=scrollElement.scrollLeft/maxScroll;}}else if(hasScrollY){const maxScroll=scrollElement.scrollHeight-scrollElement.clientHeight;if(maxScroll>0){progress=scrollElement.scrollTop/maxScroll;}}if(isReversed){progress=1-progress;}setScrollProgress(Math.min(1,Math.max(0,progress)));};scrollElement.addEventListener(\"scroll\",handleScroll,{passive:true});window.addEventListener(\"resize\",handleScroll);handleScroll()// Initial calculation\n;return()=>{scrollElement.removeEventListener(\"scroll\",handleScroll);window.removeEventListener(\"resize\",handleScroll);};};// Try to find section immediately\nlet cleanupFn=findAndTrackSection();// Retry after delay in case DOM is still loading\nconst retryTimeouts=[100,500,1e3,2e3];const timeoutIds=[];retryTimeouts.forEach(delay=>{const id=setTimeout(()=>{if(!scrollElementRef.current){const newCleanup=findAndTrackSection();if(newCleanup){if(cleanupFn)cleanupFn();cleanupFn=newCleanup;}}},delay);timeoutIds.push(id);});cleanup=()=>{timeoutIds.forEach(clearTimeout);if(cleanupFn)cleanupFn();};}return cleanup;},[trackingMode,sectionName,isReversed]);// Preview in canvas\nif(RenderTarget.current()===RenderTarget.canvas){return /*#__PURE__*/_jsx(\"div\",{style:{...style,backgroundColor,overflow:\"hidden\",position:\"relative\"},children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",width:\"40%\",height:\"100%\",backgroundColor:fillColor,left:direction===\"left\"?0:\"auto\",right:direction===\"right\"?0:\"auto\",top:0}})});}return /*#__PURE__*/_jsx(\"div\",{style:{...style,backgroundColor,overflow:\"hidden\",position:\"relative\"},children:/*#__PURE__*/_jsx(motion.div,{style:{position:\"absolute\",backgroundColor:fillColor,height:\"100%\",width:`${scrollProgress*100}%`,top:0,...direction===\"left\"?{left:0}:{right:0}},initial:false,animate:{width:`${scrollProgress*100}%`},transition:{type:\"spring\",damping:30,stiffness:400}})});}// Property Controls\naddPropertyControls(ScrollSectionNav,{trackingMode:{type:ControlType.Enum,title:\"Track\",options:[\"page\",\"section\"],optionTitles:[\"Page\",\"Section\"],defaultValue:\"page\",displaySegmentedControl:true},sectionName:{type:ControlType.String,title:\"Section Name\",placeholder:\"test or #test\",description:\"Enter the exact name of your Scroll Section\",hidden:props=>props.trackingMode===\"page\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left\",\"right\"],optionTitles:[\"→\",\"←\"],defaultValue:\"left\",displaySegmentedControl:true},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#E5E5E5\"},fillColor:{type:ControlType.Color,title:\"Fill\",defaultValue:\"#0099FF\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollSectionNav\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"* @framerIntrinsicWidth 400\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicHeight\":\"8\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Scroll_Progress_Bar.map"],"mappings":"8PASG,S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