Answer the question
In order to leave comments, you need to log in
How to change the color of an element when crossing screens (when scrolling)?
Required for javascript.
Let's say the template looks like this:
<div id="block"></div>
<section></section>
<section></section>
<section></section
Answer the question
In order to leave comments, you need to log in
Hello, I have done such things through.
Finding coordinates in js
If there are better options, I'm ready to listen too.
It is done by analogy with the stick menu . Just add a few conditions.
You need to know:
1) The value of the sections relative to the top of the page:
topPos = element.offsetTop
2) The height of the sections:
h = document.getElementById('A').clientHeight ||
h = document.getElementById('A').offsetHeight ||
h = document.getElementById('A').scrollHeight ||
Something like this, I think you will finalize it for yourself:
https://jsfiddle.net/bingo347/mxgr2vet/
IntersectionObserver doc: https://developer.mozilla.org/en/docs/Web/API/Inte... Polyfill
(no native in safari and ie): https://github.com/w3c/IntersectionObserver/blob/m...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question