In many apps, news or display classes have the effect of drop-and-pull loading, the Internet provides a third-party class to achieve this effect (see Mjrefresh and Egotableviewpullrefresh for details), but in the spare time, we can think about it, The principle of this effect is what I have said before, as long as the animation is deceptive, as long as not a hardware problem most of the results can be based on the system UI.
The following pull down through the jquery mobile phone to refresh the page code, very much like QQ space client or micro-letter Drop-down Refresh page effect code.
Please see the following effect chart:
Online preview Source Download
HTML code:
<div id= "wrapper" > <ul> <li>row </li> <li>row </li> <li>row </li> <li>row </li> <li>row </li> <li>row </li> <li>row </li> <LI&G T;row </li> <li>row </li> <li>row </li> </ul> </div> <script> for (var i =; I < Document.queryselectorall ("#wrapper ul li"). length; i++)
{Document.queryselectorall ("#wrapper ul li") [I].COLORFULBG (); } refresher.init ({id: "wrapper",//<--------------------------------------------------------------------------
----------┐pulldownaction:refresh, pullupaction:load});
var generatedcount =;
function Refresh () {settimeout (function () {//<--simulate network congestion, remove settimeout from production!
Var El, Li, I;
el = Document.queryselector ("#wrapper ul");
el.innerhtml = ';
for (i =; I < i++) {li = document.createelement (' li '); Li.appendchILD (document.createTextNode (' async row ' + (++generatedcount)));
El.insertbefore (Li, el.childnodes[]); Wrapper.refresh ();/****remember to refresh after action completed! ---yourid.refresh (); ----| /for (var i = i < Document.queryselectorall ("#wrapper ul li"). Length; i++) {Document.queryselectorall ("#wr
Apper ul li ") [I].COLORFULBG ();
}
}, );
function Load () {settimeout (function () {//<--simulate network congestion, remove settimeout from production!
Var El, Li, I;
el = Document.queryselector ("#wrapper ul");
for (i =; I < i++) {li = document.createelement (' li ');
Li.appendchild (document.createTextNode (' async row ' + (++generatedcount)));
El.appendchild (Li, el.childnodes[]); Wrapper.refresh ();/****remember to refresh after action completed!!! ---id.refresh (); ---****/for (var i = i < Document.queryselectorall ("#wrapper ul li"). Length; i++) {Document.queryselectorall (
"#wrapper ul li") [I].COLORFULBG (); }
},);
} </script>
Pull down refresh and load more on the principle detailed, specific introduction through code analysis.
The code is as follows:
The principle of Drop-down refresh-(void) scrollviewwillbegindecelerating: (Uiscrollview *) ScrollView {if (Scrollview.contentoffset.y <- {[UIView animatewithduration:1.0 animations:^{/frame offset, distance from the top 150 (can be set by itself) Self.tableView.contentI
Nset = Uiedgeinsetsmake (150.0f, 0.0f, 0.0f, 0.0f);
completion:^ (BOOL finished) {/** * initiates a network request, requests to refresh the data *}]; }//Pull load principle-(void) scrollviewdidenddragging: (Uiscrollview *) ScrollView willdecelerate: (BOOL) decelerate {NSLog (
@ "%f", SCROLLVIEW.CONTENTOFFSET.Y);
NSLog (@ "%f", scrollView.frame.size.height);
NSLog (@ "%f", scrollView.contentSize.height); /** * Key--> * ScrollView There is no offset at first, but the size of the contentsize will be set, so contentsize.height will always be taller than contentoffset.y a mobile screen's * height; pull load The effect is that each slide to the bottom, and then pull up when the request for more, that time the offset, you can make CONTENTOFFSET.Y + mobile screen size taller than this * a scrolling view of the contentsize.height */if (scrollview.co Ntentoffset.y + scrollView.frame.size.height >= scrollView.contentSize.height) {NSLog (@ "%d%s", __line__,__
FUNCTION__); [UiviEW Commitanimations]; [UIView animatewithduration:1.0 animations:^{/frame offset, up from the bottom up to 60 (can be set by itself) Self.tableView.contentInset = Uiedgei
Nsetsmake (0, 0, 60, 0);
completion:^ (BOOL finished) {/** * initiates a network request, requesting more data to be loaded * Then change the contentinset to (0,0,0,0)/} When the data request comes back;
}
}
The above is this article for the jquery simulation of the original eco-app pull refresh Drop-down load more pages and principles of detailed, I hope to help.