Skip to content

srcagency/touchy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Detect a touch device and apply classes for CSS scoping

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published