In an ionic app, I am watching the on-swipe-right
directive to implement a "Back" feature.
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
And in the controller
angular.module('my-app', [
'ui.router'
])
.controller 'DoloresMainCtrl', ($scope, $state)->
$scope.toMainScreen = ($event)->
$state.go '^' if $event?.gesture?.touches?.length is 2
The event fires just fine, but $event.gesture.touches.length
is always 1
.
What do I need to set to get ionic to detect multiple touches?
(Constraints: Android 4.4+, iOS 8+)
Here is a working example that can detect multiple touch points for tap events. The touchstart of the points have to be very simultaneous to count as multi-tap. Otherwise they are perceived as two sequential taps.
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 example:
<ion-content class="padding" multi-tap>