Hi guys!
I’m using the following template:
<div class="radio-wrapper" on-swipe-left="left()" on-swipe-right="right()"></div>
But when i use a small movement the swipe does not trigger. It triggers only when I’m swiping from one side of the screen to another.
Any ideias?
Problem solved using touchstart, move and end events.
Just a heads up, Ionic has built in gestures that you can use in your directives.
http://ionicframework.com/docs/api/utility/ionic.EventController/#onGesture
As I can see you could solve your problem about long movements on swipe using touchstart, move and end events.
I have exactly the same problem, and I need short movements on swipe. Can you help me with any sample ?
thanks in advance.
I’ve created a directive and here it is the link function:
link: function(scope, element, attrs, ngModel) {
var startX;
element.on('touchstart', function(e) {
startX = e.touches[0].pageX;
});
element.on('touchmove', function(e) {
e.preventDefault();
});
element.on('touchend', function(e) {
var diff = startX - e.changedTouches[0].pageX;
if(diff > 0) {
left();
}
else if (diff < 0) {
right();
}
});
}