html5在手機(jī)上手指左右滑動(dòng)切換頁(yè)面,哪位大蝦做過(guò),給個(gè)列子?
例如:http://imag.jimi.com/dx/
這個(gè)有何難啊,使用?touchwipe.js?很簡(jiǎn)單的就能實(shí)現(xiàn)了
你發(fā)的另外一個(gè)貼子我回復(fù)了。
這個(gè)有何難啊,使用?touchwipe.js?很簡(jiǎn)單的就能實(shí)現(xiàn)了
能給個(gè)列子不?
這個(gè)有何難啊,使用?touchwipe.js?很簡(jiǎn)單的就能實(shí)現(xiàn)了
<script>jq1.9min.js</script><script>(function(a){ a.fn.touchwipe=function(c){ var b={ drag:false, min_move_x:20, min_move_y:20, wipeLeft:function(){/*向左滑動(dòng)*/}, wipeRight:function(){/*向右滑動(dòng)*/}, wipeUp:function(){/*向上滑動(dòng)*/}, wipeDown:function(){/*向下滑動(dòng)*/}, wipe:function(){/*點(diǎn)擊*/}, wipehold:function(){/*觸摸保持*/}, wipeDrag:function(x,y){/*拖動(dòng)*/}, preventDefaultEvents:true }; if(c){a.extend(b,c)}; this.each(function(){ var h,g,j=false,i=false,e; var supportTouch = "ontouchstart" in document.documentElement; var moveEvent = supportTouch ? "touchmove" : "mousemove", startEvent = supportTouch ? "touchstart" : "mousedown", endEvent = supportTouch ? "touchend" : "mouseup" /* 移除 touchmove 監(jiān)聽(tīng) */ function m(){ this.removeEventListener(moveEvent,d); h=null; j=false; clearTimeout(e) }; /* 事件處理方法 */ function d(q){ if(b.preventDefaultEvents){ q.preventDefault() }; if(j){ var n = supportTouch ? q.touches[0].pageX : q.pageX; var r = supportTouch ? q.touches[0].pageY : q.pageY; var p = h-n; var o = g-r; 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 處理方法*/ function k(){clearTimeout(e);if(!i&&j){b.wipe()};i=false;j=false;}; /*wipehold 處理方法*/ function l(){i=true;b.wipehold()}; function f(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){ this.addEventListener(startEvent,f,false); this.addEventListener(endEvent,k,false) //} }); return this };})(jQuery);/* 調(diào)用*/$("#aa").touchwipe({ wipeLeft:function(){ alert("向左滑動(dòng)了")}, wipeRight:function(){alert("向右滑動(dòng)了")},})</script><div id="aa"> abcde </div>
這個(gè)有何難啊,使用?touchwipe.js?很簡(jiǎn)單的就能實(shí)現(xiàn)了
<script>jq1.9min.js</script><script>(function(a){ a.fn.touchwipe=function(c){ var b={ drag:false, min_move_x:20, min_move_y:20, wipeLeft:function(){/*向左滑動(dòng)*/}, wipeRight:function(){/*向右滑動(dòng)*/}, wipeUp:function(){/*向上滑動(dòng)*/}, wipeDown:function(){/*向下滑動(dòng)*/}, wipe:function(){/*點(diǎn)擊*/}, wipehold:function(){/*觸摸保持*/}, wipeDrag:function(x,y){/*拖動(dòng)*/}, preventDefaultEvents:true }; if(c){a.extend(b,c)}; this.each(function(){ var h,g,j=false,i=false,e; var supportTouch = "ontouchstart" in document.documentElement; var moveEvent = supportTouch ? "touchmove" : "mousemove", startEvent = supportTouch ? "touchstart" : "mousedown", endEvent = supportTouch ? "touchend" : "mouseup" /* 移除 touchmove 監(jiān)聽(tīng) */ function m(){ this.removeEventListener(moveEvent,d); h=null; j=false; clearTimeout(e) }; /* 事件處理方法 */ function d(q){ if(b.preventDefaultEvents){ q.preventDefault() }; if(j){ var n = supportTouch ? q.touches[0].pageX : q.pageX; var r = supportTouch ? q.touches[0].pageY : q.pageY; var p = h-n; var o = g-r; 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 處理方法*/ function k(){clearTimeout(e);if(!i&&j){b.wipe()};i=false;j=false;}; /*wipehold 處理方法*/ function l(){i=true;b.wipehold()}; function f(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){ this.addEventListener(startEvent,f,false); this.addEventListener(endEvent,k,false) //} }); return this };})(jQuery);/* 調(diào)用*/$("#aa").touchwipe({ wipeLeft:function(){ alert("向左滑動(dòng)了")}, wipeRight:function(){alert("向右滑動(dòng)了")},})</script><div id="aa"> abcde </div>
jq1.9min.js這個(gè)文件在哪下載
HTML怎么學(xué)習(xí)?HTML怎么入門(mén)?HTML在哪學(xué)?HTML怎么學(xué)才快?不用擔(dān)心,這里為大家提供了HTML速學(xué)教程(入門(mén)課程),有需要的小伙伴保存下載就能學(xué)習(xí)啦!
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://m.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)