0.0.3 • Published 6 years ago

is-touchy v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Touchy

Test

.. if a browser is run on a touch device.

var touchy = require('is-touchy');
touchy(window);	// true/false

Mark

.. 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.

Toggle

.. 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);

License

MIT © src.agency / Thomas Jensen