Use of onscroll on the mobile side

Source: Internet
Author: User

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
    1. 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.
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.