D
D
Delakey Blackhole2016-08-22 23:42:18
JavaScript
Delakey Blackhole, 2016-08-22 23:42:18

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);

tried using $ionicGesture the result was the same

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2016-08-23
@AMar4enko

What specific event did you use in $ionicGesture? Because there is no touchend.
But there are great drag events

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question