Преглед изворни кода

#4883 Func to detect touch devices and devices with pointers

Alex Trofimov пре 1 година
родитељ
комит
b2691f5099
1 измењених фајлова са 10 додато и 0 уклоњено
  1. 10 0
      inc/js/functions.js

+ 10 - 0
inc/js/functions.js

@@ -1482,6 +1482,16 @@ function bx_set_color_scheme_html()
         $('html').removeClass('dark')
 }
 
+function bx_is_mouse()
+{
+    return matchMedia('(pointer:fine)').matches;
+}
+
+function bx_is_touch_device()
+{
+    return (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0));
+}
+
 /**
  * Check if mobile or desktop device.
  */