Redux Made Easy Beginner's Guide to State Management in React JS bilal shafqat
Redux Made Easy: Beginner’s Guide to State Management in React JS
November 9, 2023
document.addEventListener('DOMContentLoaded', function() { const svgPath = document.querySelector('#scrollLine'); if (svgPath) { const pathLength = svgPath.getTotalLength(); svgPath.style.strokeDasharray = pathLength; svgPath.style.strokeDashoffset = pathLength; window.addEventListener('scroll', function() { const scrollTop = window.pageYOffset; const windowHeight = window.innerHeight; const documentHeight = document.documentElement.scrollHeight - windowHeight; const scrollPercent = scrollTop / documentHeight; svgPath.style.strokeDashoffset = pathLength * (1 - scrollPercent); }); } else { console.error("SVG path with ID 'scrollLine' not found."); } });