jquery plugin iscroll to achieve Drop-down refresh, scrolling effect _jquery

Source: Internet
Author: User
Tags wrapper

jquery Plugin: Iscroll

Page layout:

<div id= "wrapper" >
  <div id= "scroller" >
   <div id= "pulldown" >
    <span class= " Pulldownicon "></span><span class=" Pulldownlabel "> Dropdown refresh ...</span>
   </div>
   < UL id= "Thelist" >
    <li>
     
    </li>
    <li>
     
    </li>
    <li>
     
    </li>
    <li>
     
    </li>
    <li>
     
    </li>
    <li>
     
    </li>
   </ul>
   <div id=" Pullup ">
    <span class=" Pullupicon "></span><span class=" Pulluplabel "> Pull load more ...</span>
   </div>
  </ Div>

Paging, is through the AJAX request, the page number into the general handler, in the general handler to get the paging data returned to the JSON array object.

Drop-down refresh:

/**
  * Drop-down Refresh (custom implementation of this method)
  * Myscroll.refresh ();//////After data loading is complete, invoke interface Update method/
  function pulldownaction () {
   settimeout (function () { 
    var el, Li, I;
    el = document.getElementById (' thelist ');
    ==========================================
    $.ajax ({
     type: "Get",
     URL: "Loadmore.ashx",
     data : {page:generatedcount},
     DataType: "JSON",
     success:function (data) {
      var json = data;
      $ (JSON). each (function () {
       li = document.createelement (' li ');
       Li.innertext = ' generated row ' + (++generatedcount);
       li.innerhtml = '  ';
       El.insertbefore (Li, El.childnodes[0]);
      })
    ;
    Myscroll.refresh (); After data loading completes, invoke interface Update method  Remember to refresh when contents are loaded (ie:on ajax completion)
   }, 1000);  <--Simulate network congestion, remove settimeout from production!
  }

Pull up Refresh

function Pullupaction () {
   settimeout (function () {  
    var el, Li, I;
    el = document.getElementById (' thelist ');
    ==========================================
    $.ajax ({
     type: "Get",
     URL: "Loadmore.ashx",
     data: { Page:generatedcount},
     DataType: "JSON",
     success:function (data) {
      var json = data;
      $ (JSON). each (function () {
       li = document.createelement (' li ');  Li.innertext = ' generated row ' + (++generatedcount);
       li.innerhtml = ' ;     
       El.insertbefore (Li, El.childnodes[0]);
      })
    ;
    ============================================
    Myscroll.refresh ()/////After data loading is complete, invoke interface Update method Remember to refresh when Contents are loaded (ie:on ajax completion)
   }, 1000); <--Simulate network congestion, remove settimeout from production!
  }

Class

/** * Initialize Iscroll control/function loaded () {Pulldownel = document.getElementById (' pulldown ');
   Pulldownoffset = Pulldownel.offsetheight;
   Pullupel = document.getElementById (' Pullup ');
   Pullupoffset = Pullupel.offsetheight;  Myscroll = new Iscroll (' wrapper ', {scrollbarclass: ' Myscrollbar ',/* Important style * * Usetransition:false, Topoffset:  Pulldownoffset, Onrefresh:function () {if (PullDownEl.className.match (' loading ')) {Pulldownel.classname
      = '';
     Pulldownel.queryselector ('. Pulldownlabel '). InnerHTML = ' drop-down refresh ... ';
      else if (pullUpEl.className.match (' loading ')) {pullupel.classname = ';
     Pullupel.queryselector ('. Pulluplabel '). InnerHTML = ' pull loading more ... ' }, Onscrollmove:function () {if (This.y > 5 &&!pulldownel.classname.match (' Flip ')) {PU
      Lldownel.classname = ' Flip ';
      Pulldownel.queryselector ('. Pulldownlabel '). InnerHTML = ' Let go of the update ... ';
     this.minscrolly = 0; else if (This.y &Lt
      5 && pullDownEl.className.match (' Flip ')) {pulldownel.classname = ';
      Pulldownel.queryselector ('. Pulldownlabel '). InnerHTML = ' drop-down refresh ... ';
     this.minscrolly =-pulldownoffset; else if (This.y < (this.maxscrolly-5) &&!pullupel.classname.match (' Flip ')) {pullupel.classname = ' F
      Lip ';
      Pullupel.queryselector ('. Pulluplabel '). InnerHTML = ' Let go of the update ... ';
     this.maxscrolly = this.maxscrolly; 
      else if (This.y > (this.maxscrolly + 5) && pullUpEl.className.match (' Flip ')) {pullupel.classname = ';
      Pullupel.queryselector ('. Pulluplabel '). InnerHTML = ' pull loading more ... '
     this.maxscrolly = Pullupoffset; }, Onscrollend:function () {if (PullDownEl.className.match (' Flip ')) {pulldownel.classname = ' Loadi
      Ng ';
      Pulldownel.queryselector ('. Pulldownlabel '). InnerHTML = ' loading ... '; Pulldownaction ();
     Execute Custom Function (Ajax call?)
else if (pullUpEl.className.match (' Flip ')) {      Pullupel.classname = ' loading ';
      Pullupel.queryselector ('. Pulluplabel '). InnerHTML = ' loading ... '; Pullupaction ();
     Execute Custom Function (Ajax call?)
   }
    }
   });
  settimeout (function () {document.getElementById (' wrapper '). Style.left = ' 0 ';}, 800);
  ///Initialize the bound iscroll control Document.addeventlistener (' Touchmove ', function (e) {E.preventdefault ();}, False); Document.addeventlistener (' domcontentloaded ', Loaded, false);

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.