JQuery Mobile swipe events in Android 4.2.2 not working

I wrote a mobile web application that uses jQuery for mobile swipeleft and swiperight, but they do not work on Samsung Galaxy S4 running Android 4.2.2. Running a web application in a standard web browser or in Chrome has the same problem: swipe events were not detected.

The following shows how I try to detect events that work perfectly on other devices on which I tested it, even on Android devices (but not on Android 4.2.2):

$('#showImage').on("swipeleft", function (event) { if (currentScale != initialScale) return; if (currentPage < maxPage) { ++currentPage; img.src = document.getElementById("page" + zeroPad(currentPage, 2) + "url").value; } }); $('#showImage').on("swiperight", function (event) { if (currentScale != initialScale) return; if (currentPage > 1) { --currentPage; img.src = document.getElementById("page" + zeroPad(currentPage, 2) + "url").value; } }); 

Is there anything I can do, by code, to capture these events in Android 4.2.2?

+4
source share
1 answer

You have two problems here.

An error was first caused in JQM that was resolved but not yet implemented https://github.com/jquery/jquery-mobile/issues/5534

Basically, the minimum distance measured by the swipe event should take into account the pixel density of the device. Thus, in the case of JQM, the following change to touch.js will solve the problem:

 horizontalDistanceThreshold = window.devicePixelRatio >= 2 ? 15 : 30; verticalDistanceThreshold = window.devicePixelRatio >= 2 ? 15 : 30; 

The second is todo with kitkat shooting touchcancel instead of touchhend. The solution is to delegate touchcancel to touch.

+1
source

Source: https://habr.com/ru/post/1502129/


All Articles