I found this ajvaScript buit that reduces the height of a div, but i need it to start after the user scrolls past an ID, how can i add this to trigger after a certain paoint?
this is the original script:
console.clear();
const div = document.querySelector('scrollthing');
window.addEventListener('scroll', () => {
console.log(window.scrollX)
scrollthing.style.height = `${400 - window.scrollY}px`;
});
something like combining it with this :
window.addEventListener("scroll", function() {
var elementTarget = document.getElementById("section-2");
if (window.scrollY > (elementTarget.offsetTop + elementTarget.offsetHeight)) {
alert("You've scrolled past the second div");
}
});
but instead of teh alert ot should changethe height
it works now but it start upon scrolling off the top which is too early if teh div is below the fold