stevemcilwaine
10/24/2019 - 1:42 PM

Mobile detect using vanilla JS

Quick function to check if the device being used is a Touch device

/**
   * Detect touch devices
   * @return {Boolean} touch check
   * @memberof SubMenu
   */
  isTouchDevice() {
    return (('ontouchstart' in window)
      || (navigator.MaxTouchPoints > 0)
      || (navigator.msMaxTouchPoints > 0));
  }