Last active
February 19, 2020 14:33
-
-
Save seyfer/0ac50671d6b28a74c60b1fd70c2d38bb to your computer and use it in GitHub Desktop.
Do not show v-tooltip for touch devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isTouchDevice() { | |
const prefixes = ' -webkit- -moz- -o- -ms- '.split(' '); | |
const mq = function(query) { | |
return window.matchMedia(query).matches; | |
}; | |
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) { | |
return true; | |
} | |
// include the 'heartz' as a way to have a non matching MQ to help terminate the join | |
// https://git.io/vznFH | |
const query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join(''); | |
return mq(query); | |
} | |
VTooltip.enabled = !isTouchDevice(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment