Includes Touch Events clientX/Y scrolling or not?

后端 未结 2 1500
清酒与你
清酒与你 2021-02-05 22:40

I\'m trying to get touch coordinates relative to the viewport of browser from touch events (such as touchstart). I tried to get them from clientX/Y pro

2条回答
  •  佛祖请我去吃肉
    2021-02-05 23:16

    Try this

    event.touches[0].pageX
    

    Note that it is always event.touches even if you define your event like this (using jquery here)

    $("body").bind('touchmove', function(e){ 
    //stops normal scrolling with touch
    e.preventDefault();
    
    console.log(event.touches[0].pageX)
    
    })
    

    ;

    The Safari guide provides more detail

提交回复
热议问题