3 /** detects whether the device supports touch events, copied from https://stackoverflow.com/a/4819886/606571 */
4 module.exports = () => {
5 // eslint-disable-next-line no-undef
6 if ('ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch)) {
10 const prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
11 // include the 'heartz' as a way to have a non matching MQ to help terminate the join
12 // https://git.io/vznFH
13 const query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
14 return window.matchMedia(query).matches;