1. Actual Requirements
?? (Mobile project) when you swipe down to a certain distance, the navigation bar is displayed, the navigation bar is positioned at the top, and the navigation bar is hidden when you swipe up and less than that distance.
2. Solution
?? Real-time Monitoring browser scrolling height, binding onscroll events, details see this article--https://github.com/merrier/mobile-scroll-events, this article is described in detail, including in Android and compatibility issues on iOS, and processing scenarios. Here are some of the words that are not in this article.
3. Problems encountered during the period
- Scrolly & pageYOffset
?? At that time, for unknown reasons, the test failed on iOS using scrolltop, after the reference article in the link above onscroll Event issues on Mobile browsers, It is found that the window.scrolly used in the example can reflect the scrolling height of the scroll bar in real time, and even the inertia scrolling can be successfully reflected. pageYOffset is the alias of scrolly, the difference is that pageyoffset compatibility is better.
- About bug problems with pageYOffset
?? The official definition is read-only, but the reality is as follows: (example of Baidu do)
(1) Bind onscroll Event
(2) Navigation switch, page scroll to 222px place, do not display the contents of the search box above
(3) the page initial in, no problem, the effect is normal. But when the navigation is switched on, the problem comes, scroll to the top, and the navigation appears,
(4) to observe the printed window.pageyoffset, after switching the navigation has been 222, what??????
How does this look like it was assigned to, a good read-only? (not yet understood ...) )
(5) The Final solution, is to remove the window.pageyoffset, no effect is normal (then quirks used this)
Use of onscroll on the mobile side