Paging to Waterfall

Source: Internet
Author: User

1. problem:
when multiple items are displayed on a single page, pagination is involved, and multiple pages are required. However, as the Internet is changing, waterfall flow occurs, I have not studied it carefully. My personal understanding is that, while the scroll bar is always pulled down, the data is always filled into the region until the request data is complete or the expected end.
the requirement is based on the function. As a result, the product change request is changed to a waterfall stream by page. If you have not studied the waterfall flow, you can imagine that you have done so, one night and one morning.
2. idea:
. set a page to pull 10 pieces of data. When the scroll bar pulls the data to the bottom, it asynchronously pulls the data from the background. After the pull is successful, the existing data on the current page is merged to fill in the current page.
B. action involved: When the page is displayed, the first page is displayed. When the scroll bar is pulled to a certain extent, the second page of data is requested asynchronously. After the data is returned in the background, the page is filled ......
C. data must be displayed in an orderly manner and pulled when it is rolled to a certain extent to ensure that the pulled data is not repeated or missing.
in fact, the key issue is when the page number increases progressively, make sure that the data is pulled.

(Function (NS) {// judge the scroll bar position var scroll = {isend: false, curpage: 1, totalpage: 1, iscroll: function () {// get something here return clientheight + scrolltop> = scrollheight-400; // 400 is the experience value} // callback function for data pulling success getdatasuccess (data) {// do something here scroll. totalpage = data. itotalpage; If (data. ipageindex> = data. itotalpage) {scroll. isend = true ;}}; // function getcurpagedatabyajax (curpage, getdatasuccess) {// do something here}; // listens to the Window Rolling event addevent (global, 'scroll', function () {If (scroll. iscroll () & scroll. isend) {scroll. curpage ++; If (scroll. curpage> scroll. totalpage) {scroll. isend = false; scroll. totalpage = 1;} else {getcurpagedatabyajax (scroll. curpage, getdatasuccess) ;}}); // pull the data at the beginning. getcurpagedatabyajax (1, getdatasuccess);}) (window );

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.