2014-10-02 17 views
1

在一個離子應用程序中,我正在觀看on-swipe-right指令以實現「返回」功能。在Ionic/Android WebView中檢測多個觸摸

doctype html5 
html(lang='en', ng-app='my-app') 
    head 
    meta(charset='utf-8') 
    meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1') 
    meta(name='viewport', content='width=device-width,initial-scale=1') 

//- snip 

    body(
    ng-controller="DoloresMainCtrl" 
    on-swipe-right="toMainScreen($event)" 
) 
    ion-nav-view 

和Controller

angular.module('my-app', [ 
    'ui.router' 
]) 
.controller 'DoloresMainCtrl', ($scope, $state)-> 
    $scope.toMainScreen = ($event)-> 
     $state.go '^' if $event?.gesture?.touches?.length is 2 

的事件觸發就好了,但$event.gesture.touches.length總是1

我需要設置什麼來獲取離子來檢測多個接觸?

(約束:機器人4.4+,iOS的8+)

+0

我也有興趣在這個問題的答案。 Ionic使用hammer.js的叉子來進行觸摸事件,而在hammer.js中,可以檢測多個觸摸,所以爲什麼不使用Ionic? – 2014-11-14 08:17:02

回答

0

這裏是一個工作示例,可以檢測多個觸摸點爲抽頭事件。觸發點必須非常同時才能算作多點擊。否則,他們被視爲兩個連續的水龍頭。

angular.module('my-app', ['ui.router']) 
    .directive('multiTap', function() { 
     return { 
      restrict: 'A', 
      link: function postLink(scope, element, attrs) { 
       element.text('this is the multi-tap directive'); 
       var tap = ionic.onGesture("tap", handler, element[0]); 
       function handler(e) { console.log(e); 
        element.text(e.type + e.gesture.touches.length); 
       } 
      } 
     }; 
    }); 

HTML例如:

<ion-content class="padding" multi-tap> 
+0

不要忽視你的答案,只是忙於其他的事情! – 2014-11-17 22:02:08