📜 ⬆️ ⬇️

Why some SPAs have stopped supporting touch events on touch laptops

Maybe I just made out right now, and everyone knows for a long time, but it turns out that in Chrome 70 they did this: The ontouch * APIs default to disabled on desktop

Accordingly, if in your code you relied on the presence of the 'ontouch *' keys in the document or window , your code will no longer determine what works on the touch device.

I ran into a typo:

var isTouchDevice = (('ontouchstart' in window) || (navigator.MaxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)); 

And when the first condition ceased to be true, the second fucked up. There should have been navigator.maxTouchPoints
')
And here, for example, in jQuery UI Touch Punch 0.2.3 , the following code is used:

  $.support.touch = 'ontouchend' in document; 

Accordingly, support is also lost.

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


All Articles