Mobile web page pull-down refresh
1. Use the touch event touchmove. 1. Define the public variable var timer = null; var startY, moveY, initTop, oldTop, newTop; 2. Add event $ ('# container ul '). on ('touchstart', function (e) {startY = e. originalEvent. touches [0]. pageY; initTop = 0 ;}); $ ('# container ul '). on ('touchmove ', function (e) {moveY = e. originalEvent. touches [0]. pageY; scrollEnd () ;}); 3. function scrollEnd () {if (timer) clearTimeout (timer); newTop =$ (window ). scrollTop (); if (newTop === oldTop) {ClearTimeout (timer); if (initTop! = NewTop) {var wHeight = $ (window ). height (); var dHeight = $ (document ). height (); if (newTop> 0) & (newTop + wHeight> = dHeight) & (startY-moveY> 0 )) {// run the Business Code }}else {oldTop = newTop; timer = setTimeout (scrollEnd, 100) ;}ii. Use the scroll event $ (window ). scroll (function () {var scrollTop = $ (this ). scrollTop (); // var distance entheight = $ (document) from the height of the scroll bar to the Y axis ). height (); // The height of the entire window var height = $ (this ). height (); // The height of the visible area if (scrollTop + height) = incluentheight) {// execute Business Code }});