Compatible with a plugin for mobile phone and PC Touchwipe

Source: Internet
Author: User

Compatible with a plug-in phone and PC, just simple up, down, left, right. have uploaded my files inside.

Http://files.cnblogs.com/files/yjhua/touchwipe.js

The source code is as follows:

/**----------------------* touchwipe *----------------------* http://www.uedcool.com * by Eddyzhang (Zhang Yonghui) * Version 2.0 * 2011/12/29 * * #example: * $ ("#test"). Touchwipe ({* min_move_x:40,//transverse sensitivity * min_move_y:40,//longitudinal sensitivity * wipeleft:function () {$ ("#val"). Append ("left,");},//left swipe event * WI Peright:function () {$ ("#val"). Append ("right,");},//Right Swipe event * Wipeup:function () {$ ("#val"). Append ("Top,");},//Slide up Event * Wipedown:function () {$ ("#val"). Append ("Down,");},//Swipe down event * Wipe:function () {$ ("#val"). Append (" Click, ");},//Touch event * Wipehold:function () {$ (" #val "). Append (" Hold, ");},//Touch Hold Event * PREVENTDEFAULTEVENTS:TR UE//block default event *}); * */(function(a) {A.fn.touchwipe=function(c) {varb={cleartouchwipe:false, drag:false, min_move_x:20, min_move_y:20, Wipeleft:function(){/*Swipe left*/}, Wiperight:function(){/*Swipe Right*/}, Wipeup:function(){/*swipe up*/}, Wipedown:function(){/*Swipe down*/}, Wipe:function(){/*Click*/}, Wipehold:function(){/*Touch Hold*/}, Wipedrag:function(x, Y) {/*Drag*/}, Preventdefaultevents:false        }; if(c) {a.extend (b,c)};  This. each (function(){            varh,g,j=false, i=false, E; varSupporttouch = "Ontouchstart"inchdocument.documentelement; varMoveevent = Supporttouch? "Touchmove": "MouseMove", Startevent= Supporttouch? "Touchstart": "MouseDown", EndEvent= Supporttouch? "Touchend": "MouseUp"/*Remove Touchmove Monitor*/            functionm () { This. RemoveEventListener (MOVEEVENT,D); H=NULL; J=false;            Cleartimeout (e)}; /*Event Handling Methods*/            functiond (q) {if(b.preventdefaultevents) {q.preventdefault ()}; if(j) {varn = supporttouch? Q.touches[0].pagex:q.pagex; varr = Supporttouch? Q.touches[0].pagey:q.pagey; varp = hN; varo = G0; if(B.drag) {h=N; G=R;                        Cleartimeout (e);                    B.wipedrag (P,o); }                    Else{                        if(Math.Abs (P) >=b.min_move_x)                            {m (); if(p>0) {b.wipeleft ()}Else{b.wiperight ()}}Else{                            if(Math.Abs (o) >=b.min_move_y)                                {m (); if(o>0) {b.wipeup ()}Else{B.wipedown ()}}}            }                }            }; /*Wipe Treatment Method*/            functionK () {cleartimeout (e);if(!I&&J) {b.wipe ()};i=false; j=false;}; /*Wipehold Treatment Method*/            functionL () {i=true; B.wipehold ()}; functionf (n) {//if (n.touches.length==1) {h = Supporttouch? N.touches[0].pagex:n.pagex; G= Supporttouch? N.touches[0].pagey:n.pagey; J=true;  This. AddEventListener (Moveevent,d,false); E=settimeout (l,750)                //}            }; //if ("Ontouchstart" in document.documentelement) {            if(b.cleartouchwipe) { This. RemoveEventListener (Startevent,f,false);  This. RemoveEventListener (Endevent,k,false); }Else{                 This. AddEventListener (Startevent,f,false);  This. AddEventListener (Endevent,k,false)            }            //}        }); return  This    };}) (jQuery);
View Code

Compatible with a plugin for mobile phone and PC Touchwipe

Related Article

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.