I'm developing a page where during the scroll, elements, at breakpoints, will stop on the screen and animate, once the final point in the scroll is reached they go back to normal scrolling page behavior.
Basically, once div X gets to the middle of the screen it position changes to fixed, and will stop at middle of the screen expanding, moving etc, as the user scrolls, and reached the final scroll point, it will stop and change from position fixed to relative staying in the same spot.
I did a prototype where once the element got to the point on the screen I wanted it to start animate, i would measure its position on the screen with the browser ruler and get the fixed position it should take from then on.
BUT this is a poor and ugly solution, with a lot of hand work.
We can get the scroll and sum up things to get the Y position, but the x position messes up for making the design responsive.
How to do with JS This change? How to get the Fixed equivalent position of a Relative element dynamically?
I dont have much experience with JS, but I'm sure there are good solutions for this.