more changes to js
This commit is contained in:
		@@ -3,26 +3,15 @@ document.addEventListener('DOMContentLoaded', function () {
 | 
				
			|||||||
    var h1 = document.querySelector('.user-index-h1');
 | 
					    var h1 = document.querySelector('.user-index-h1');
 | 
				
			||||||
    var h2 = document.querySelector('.user-index-h2');
 | 
					    var h2 = document.querySelector('.user-index-h2');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Function to check if an element is in the viewport
 | 
					 | 
				
			||||||
    function isInViewport(element) {
 | 
					 | 
				
			||||||
        var rect = element.getBoundingClientRect();
 | 
					 | 
				
			||||||
        return (
 | 
					 | 
				
			||||||
            rect.top >= 0 &&
 | 
					 | 
				
			||||||
            rect.left >= 0 &&
 | 
					 | 
				
			||||||
            rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
 | 
					 | 
				
			||||||
            rect.right <= (window.innerWidth || document.documentElement.clientWidth)
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Function to handle the scroll event
 | 
					    // Function to handle the scroll event
 | 
				
			||||||
    function handleScroll() {
 | 
					    function handleScroll() {
 | 
				
			||||||
        if (isInViewport(headerText)) {
 | 
					        // Calculate the opacity based on the scroll position
 | 
				
			||||||
            h1.classList.add('visible');
 | 
					        var scrollFraction = window.scrollY / (document.documentElement.scrollHeight - window.innerHeight);
 | 
				
			||||||
            h2.classList.add('visible');
 | 
					        var opacity = 1 - scrollFraction;
 | 
				
			||||||
        } else {
 | 
					
 | 
				
			||||||
            h1.classList.remove('visible');
 | 
					        // Apply the opacity to the elements
 | 
				
			||||||
            h2.classList.remove('visible');
 | 
					        h1.style.opacity = opacity;
 | 
				
			||||||
        }
 | 
					        h2.style.opacity = opacity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Attach the handleScroll function to the scroll event
 | 
					    // Attach the handleScroll function to the scroll event
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user