.. if a browser is run on a touch device.
var touchy = require('is-touchy');
touchy(window); // true/false
.. the <html>
element with classes.
var touchy = require('is-touchy');
touchy.mark(window);
<html class="touch">
<html class="no-touch">
html.no-touch a:hover {
color: pink;
}
You can add any or none of these two classes by default. If present and test shows otherwise it will be removed.
Since most touch devices run moderne browsers it is often preferable to
have no-touch
as the default.
.. classes on any DOM element
toggle(element, switch)
var touchy = require('is-touchy');
touchy.toggle(document.querySelector('#some-id'), touchy(window));
var touchy = require('is-touchy');
touchy.toggle(document.querySelector('#some-id'), true);
MIT © src.agency / Thomas Jensen