javascript--add more controls on a jquery-based imitation mobile-side pull-up

Source: Internet
Author: User

Simple implementation of the phone pull-up load more, by triggering the trigger () event, triggering the original already written request

CSS Styles

. more {                padding: 10px 10px;                 height:50px;                 background:#fff;                 background-clip:content-box;                 text-align: Center;                 line-height:50px;                 font-family:"Microsoft Yahei";                 display: none;                }

HTML code

        <class= "More"  data-page= "1"  data-rname= "" >             load More         </div>        

JS Code

1 /**2 * Achieve scrolling effect3  */4$(function(){5     varClienth = $ (window). Height ();//Screen Height6     varH =$ (document). Height ()-$ (window). scrolltop ();7     varTimer =NULL;8$ (window). On ("Touchmove",function(){9         varSCROLLH =$ (document). Height ();TenH = scrollh-$ ( This). scrolltop (); One         if(Clienth >=h) { A$ (". More"). Show (); -Timer = SetTimeout (function(){ -$ (". more"). HTML ("Release load"); the}, 1000); -}Else if(Clienth >= h-$ (". More"). Height ()) { -              -$ (". more"). HTML ("load More"); +$ (". More"). Hide (); -         } +     }); A     //record start press down to release time at  -     varStartTime, EndTime; -$ (window). On ("Touchstart",function(event) { -StartTime =NewDate (). GetTime (); -$ (". more"). HTML ("load More"); -     }); in$ (window). On ("Touchend",function(event) { -H =$ (document). Height ()-$ (window). scrolltop (); to         if(Clienth >=h) { +EndTime =NewDate (). GetTime (); -             if(Endtime-starttime > 900){ the$ (". more"). Trigger ("click")); *$ (". More"). Show (); $$ (". more"). html ("Loading ...");Panax Notoginseng}Else{ - cleartimeout (timer); the$ (". more"). HTML ("load More"); +$ (". More"). Hide (); A                  the             } +}Else{ - cleartimeout (timer); $$ (". more"). HTML ("load More"); $$ (". More"). Hide (); -              -         } the          -     });Wuyi});

javascript--add more controls on a jquery-based imitation mobile-side pull-up

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.