Is there a way to determine if an element is scrolled behind another element that is fixed at the top?
I am looking to trigger some javascript when an element is positioned below a fixed element and every height or scrollTop thereafter.
I am attempting to create a sticky header, but simply using fixed positioning based on scrollTop is not sufficient. This is because the element I want to make sticky gets pushed down as the viewport size changes, requiring a different scrollTop value to fix the element in place.
This has led me to consider the possibility of fixing/stickying the element only when it is underneath another element that is already fixed at the top.
So far, I have experimented with:
position:sticky;
along with its necessary vendor prefixes, along with trying out these two polyfills: