that's a good question.
take a look, in fact, the principle is relatively simple, but need to deal with related events, the specific implementation is still relatively tedious.
there are a total of 5 round broadcasts. The height of each rotation is the same as that of the current page and there is a parent container on the outside. The height of the parent container is the sum of the height of the five rotation.
when not scrolling to this area, all five broadcasts use absolute positioning. Once scrolled to this area, it will switch to fixed positioning and stick to the upper edge of the browser. At the same time, the scrolling distance is calculated, and only one rotation is displayed at the same time, and it will be switched to another when it is out of one rotation area.
so the browser scroll bar we see scrolls normally, because the browser scrolls five rotational parent containers. On the other hand, the display of the five rotations is switched by setting transparency. Personally, I think this practice of transparency is not very good and will affect performance, and it may be better to use display or visibility instead.
is mainly achieved by listening for scroll bar changes.
/ / listen for scroll bar changes
window.addEventListener ('scroll', () = > {
)
const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
//scrollTopindex
});