Answer the question
In order to leave comments, you need to log in
How to properly handle touchend in ionicframework?
I'm trying to switch with a swipe (left to right)
in the browser on the computer, it works without problems,
but for some reason the touchend event does not work on the phone, while the rest work without problems.
I have the following code in my controller
var toush_str = false;
var posx = 0;
var posy = 0;
var touch = 0;
$('body')[0].addEventListener('touchstart', function (event) {
toush_str = true;
var touch = event.targetTouches[0];
posx = touch.pageX;
posy = touch.pageY;
}, true);
$('body')[0].addEventListener('touchmove', function (event) {
touch = event.targetTouches[0];
}, true);
$('body')[0].addEventListener('touchend', function (event) {
//touch = event.targetTouches[0];
if (toush_str) {
var smeX = touch.pageX - posx;
var smeY = touch.pageY - posy;
if (smeX > 100) {
console.log("down day");
var day = $scope.day;
day--;
if (day < 0) day = 6;
$scope.OpenedDay = $scope.weelk[day];
$scope.$digest();
}
if (smeX < -100) {
console.log("next day");
var day = $scope.day;
day++;
if (day > 6) day = 0;
$scope.OpenedDay = $scope.weelk[day];
$scope.$digest();
}
toush_str = false;
}
}, true);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question