We all know that there is no touch event in jquery, so the use of native JS on the mobile side of the pull-up loading effect is very good, gossip not much to say, the code is as follows:
1 //gets the element to manipulate2 varObjsection = document.getElementsByTagName ("div") [0];3 //to bind an element to listen to an event personal habits write a listening event in a piece4Objsection.addeventlistener ("Touchstart", Touchstart,false);5Objsection.addeventlistener ("Touchmove", Touchmove,false);6Objsection.addeventlistener ("Touchend", Touchend,false);7 8 //Touchstart the method to execute when triggering an event9 functionTouchstart (event) {Ten Event.preventdefault (); One This. Starty = Event.changedtouches[0].pagey; A } - - //TouchMove method of executing a process triggering an event the functionTouchMove (event) { - varChange = Event.changedtouches[0].pagey- This. Starty; - This. Change =Change ; - This. parentnode.style["-webkit-transform"] = "translate (0," + This. Change + "px"); + This. parentnode.style["Transform"] = "translate (0," + This. Change + "px"); - This. parentnode.style["-webkit-transition"] = "All" + 0 + "s"; + This. parentnode.style["transition"] = "All" + 0 + "s"; A } at - //Touchend Event End Execution Method - functionTouchend (event) { - if( This. Change < 0) { - This. parentnode.style["-webkit-transform"] = "translate (0," + This. Change + "px"); - This. parentnode.style["Transform"] = "translate (0," + This. Change + "px"); in This. parentnode.style["-webkit-transition"] = "All" + 1 + "s"; - This. parentnode.style["transition"] = "All" + 1 + "s"; toAppendData ( This); +}Else { - This. parentnode.style["-webkit-transform"] = "translate (0," + 0 + "px)"; the This. parentnode.style["Transform"] = "translate (0," + 0 + "px)"; * This. parentnode.style["-webkit-transition"] = "all" + 0.5 + "s"; $ This. parentnode.style["transition"] = "all" + 0.5 + "s";Panax Notoginseng } -}
Pull up load more places to note: In the trigger pull this action to record the current page of the Pagey, at the end of the action recorded in the page Pagey, the end of the pagey-at the beginning of the Pagey to change Pagey, in doing CSS3 animation need to use the change of Pagey, Touchend inside the AppendData method for Ajax Request data method, not in here to repeat
Simple implementation of the basic functions, if necessary, can be based on the implementation of more functions
You are welcome to criticize
Native JS mobile Touch event for pull-up loading more