2012-12-04 65 views
8

我問如果Phonegap應用程序能夠識別JavaScript中的swipeLeft和SwipeRight相關事件。phonegap:是否有可能從Javascript檢測swipeLeft和SwipeRight觸摸?

+0

您在使用任何類型的框架或插件刷卡行爲的特點? – zvona

+0

我正在使用HTML5,Javascript和css3來製作Android中的phonegap應用程序 – Gaurav

+0

[在iPhone和Android上檢測通過JavaScript的手指滑動]可能的重複(http://stackoverflow.com/questions/2264072/detect-a-手指輕掃通過JavaScript的iPhone和Android) – givanse

回答

4

我們使用quo.js。它是處理多點觸摸事件等的輕量級框架。

+0

嗨丹感謝您的幫助,它會在quo.js的幫助下正常工作 – Gaurav

+0

不要使用它,它的越野車在V4超過 –

5

的PhoneGap不給你了觸摸事件比你,否則與普通的移動網站獲得。即它只是包裝一個UIWebView(在iOS上)或任何其他平臺上的等價物。在移動瀏覽器

觸摸事件包括touchstarttouchendtouchmove

有沒有任何花哨的刷卡事件,或雙擊事件,或像在移動瀏覽器本身實現什麼。

但是你可以通過結合使用JavaScript和股票touchstarttouchend事件等模擬那些更復雜的事件

幸運的是,你並不需要,因爲幾乎所有的移動框架已經這樣做了,打擾自己寫的那些事件爲你。其他人提到了一些處理觸摸事件的庫。

我自己,我傾向於使用jQuery Mobile,其中包含swipeleftswiperight事件以及其他事件。

http://jquerymobile.com/demos/1.2.0/docs/api/events.html

你甚至不必使用完整的jQuery Mobile框架,如果你不想。如果需要,您可以只包含觸摸事件處理程序。

2

使用this其工作在ios和Android與phonegap。

$("#test").swipe({ 
    click:function(event, target) { 
     log("click from callback"); 
    }, 
    swipe:function(event, direction, distance, duration, fingerCount) { 
     log("swipe from callback"); 
    }, 
    swipeLeft:function(event, distance, duration, fingerCount) { 
     log("swipeLeft from callback"); 
    }, 
    swipeRight:function(event, distance, duration, fingerCount) { 
     log("swipeRight from callback"); 
    }, 
    swipeUp:function(event, distance, duration, fingerCount) { 
     log("swipeUp from callback"); 
    }, 
    swipeDown:function(event, distance, duration, fingerCount) { 
     log("swipeDown from callback"); 
    }, 
    swipeStatus:function(event, phase, direction, distance, duration, fingers) { 
     log("swipeStatus from callback"); 
    }, 
    pinchIn:function(event, direction, distance, duration, fingerCount, pinchZoom) { 
     log("pinchIn from callback"); 
    }, 
    pinchOut:function(event, direction, distance, duration, fingerCount, pinchZoom) { 
        log("pinchOut from callback"); 
    }, 
    pinchStatus:function(event, phase, direction, distance , duration , fingerCount, pinchZoom) { 
        log("pinchStatus from callback"); 
    }, 
       fingers:$.fn.swipe.fingers.ALL 
    }); 
+0

什麼這是使用雖然,我認爲這是使用JQuery移動正確?或者它使用Zepto還是? – Gurnard

+0

這些都是TouchSwipe api的所有事件和回調1)http://labs.rampinteractive.co.uk/touchSwipe/demos/Handlers_and_events.html – Ved

+0

工作比jquery移動滑動事件更好 – Patel

相關問題