Search code examples
javascriptjqueryjquery-mobilesamsung-mobile

samsung S3 leftswipe and right swipe not working in one touch


i created one mobile app with jquery mobile everything is working fine but in samsung phones left swipe and right swipe is not working properly.

its working after 2-3 swipe.

it can be handled with

var startCoords;
        $(document.body).on("touchstart", function(event) {
            startCoords = event.originalEvent.targetTouches[0];
        });

        document.addEventListener('touchmove', function(e) {
            var touchmoveEvent = e.touches[0];
            if(touchmoveEvent.pageX && Math.abs(startCoords.pageX - touchmoveEvent.pageX) > 10)
                e.preventDefault();
        }, false);

But if i am adding this code zoom and pinch is not working... any pointer to fix this problem will be very helpful.

note : problem in all samsung phone but my requirment is for S3 only


Solution

  • var startCoords;
    $(document).on("touchstart", function(event) {
        startCoords = event.originalEvent.touches[0];
    }).on('touchmove', function(event) {
        var endCoords = event.originalEvent.touches[0];
        if(Math.abs(startCoords.pageX - endCoords.pageX) > 10) {
            alert('Swipe event');
        }
    });
    

    Checked on S3. Alert works.