23 lines
817 B
JavaScript
23 lines
817 B
JavaScript
document.addEventListener('DOMContentLoaded', function () {
|
|
var headerText = document.getElementById('headerText');
|
|
var h1 = document.querySelector('.user-index-h1');
|
|
var h2 = document.querySelector('.user-index-h2');
|
|
|
|
// Function to handle the scroll event
|
|
function handleScroll() {
|
|
// Calculate the opacity based on the scroll position
|
|
var scrollFraction = window.scrollY / (document.documentElement.scrollHeight - window.innerHeight);
|
|
var opacity = 1 - (scrollFraction*2);
|
|
|
|
// Apply the opacity to the elements
|
|
h1.style.opacity = opacity;
|
|
h2.style.opacity = opacity;
|
|
}
|
|
|
|
// Attach the handleScroll function to the scroll event
|
|
window.addEventListener('scroll', handleScroll);
|
|
|
|
// Initial check on page load
|
|
handleScroll();
|
|
});
|