All files / env touchable.js

100% Statements 5/5
60% Branches 3/5
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                      1x     1x 1x     1x     1x  
/**
 * 判断浏览器是否支持触摸屏
 * @method env/touchable
 * @returns {Boolean} 是否支持触摸屏
 * @example
 * var $touchable = require('@spore-ui/kit/packages/env/touchable');
 * if ($touchable()) {
 *   // It is a touch device.
 * }
 */
 
var isTouchable = null;
 
function touchable() {
  Eif (isTouchable === null) {
    isTouchable = !!('ontouchstart' in window
    || (window.DocumentTouch && document instanceof window.DocumentTouch));
  }
  return isTouchable;
}
 
module.exports = touchable;