Created
August 14, 2014 04:06
-
-
Save Elbone/1bed3661e463f2e06d26 to your computer and use it in GitHub Desktop.
Touch or mouse?
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
| // jQuery touch or pointer class for css | |
| $(document).on('touchstart mouseenter mouseover', function (event) { | |
| var touchOrPointer = 'touch'; // Default | |
| var touchClass = 'now-touch'; | |
| var pointerClass = 'now-pointer' | |
| if (event.type == 'touchstart') { | |
| $('body').removeClass(pointerClass).addClass(touchClass); | |
| touchOrPointer = 'touch'; | |
| } | |
| else { | |
| $('body').removeClass(touchClass).addClass(pointerClass); | |
| touchOrPointer = 'pointer'; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment