Iphone's safari touchmove event not working

Asked
Active3 hr before
Viewed126 times

5 Answers

iphoneworkingsafari
90%

Thanks for contributing an answer to Stack Overflow!, Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers , Fast intercontinental Remote Desktop Sessions ,Stack Overflow en español

Try using e.originalEvent.touches:

$('#movieShow').bind('touchmove', function(e) {
   e.preventDefault();

   var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
   console.log(touch.pageX);
});
load more v
88%

Does the touchmove event NOT work on the iPhone’s Safari browser?I’m not talking about an iOS App, just a regular old HTML page with some Javascript and jQuery that’s loaded into the iPhone’s Safari Browser.,I actually connected my iPhone to my Mac-mini – which is also running Safari, so I can see everything that’s happening on the iPhone in the Mac-Mini’s Safari console – and my touchstart and touchend events DO fire, but touchmove just does NOT respond.,I can’t see any other way of tackling this unless touchmove starts playing nicely.,What I’m ultimately trying to do is get a custom pinch-zoom type behavior going, and my understanding is that this has to be implemented in the touchmove event – so that’s why I’m asking.

Here’s the code:

        document.addEventListener("touchstart", onMobileTouchStart, false);
        document.addEventListener("touchmove", onMobileTouchMove, false);
        document.addEventListener("touchend", onMobileTouchEnd, false);

        function onMobileTouchStart(touchStartEvent) {
           console.log("n==>'onMobileTouchStart'!!!");
           touchStartEvent.preventDefault();
        }

        function onMobileTouchMove(moveEvent) {
           console.log("n==>onMobileTouchMOVE'!!!");
           moveEvent.preventDefault();
        }

        function onMobileTouchEnd(touchEndEvent) {
           console.log("n==>onMobileTouchEnd'!!!");
        }
72%

It looks like the workaround,doesn't work anymore with iOS 11.3 Mobile Safari. Is there a new workaround? 😅 It looks like that the same issue applies to Chrome on iOS as well.,If you're targeting this code to Safari iOS11.3 than it's perfectly valid since its supporting the new addEventListener api.,I'll take a look if the detection for passive event listeners works for iOS 11.3 - if it does already apply { passive:false } and it still does not work than this is going to be a fun thing for anybody trying to prevent touchmove do its thing 😞

window.addEventListener('touchmove', function() {});
load more v
65%

Попробуйте использовать e.originalEvent.touches : , Что такое событие 'touchmove'? , Можно ли использовать UDP в Flash/ActionScript? ,Попробуйте это и посмотрите, не получите ли вы по-прежнему никаких результатов:

я использую событие jquery и touchmove, но код ничего не показывает в #info

$('#movieShow').bind('touchmove', function(e) {
   e.preventDefault();
   $('#info').text(e.touches[0].pageX);
});
load more v
75%

A Boolean value indicating whether or not the alt key was down when the touch event was fired.,A Boolean value indicating whether or not the shift key was down when the touch event was fired.,A Boolean value indicating whether or not the meta key was down when the touch event was fired.,A Boolean value indicating whether or not the control key was down when the touch event was fired.

load more v