Created
November 27, 2012 12:02
-
-
Save SebAshton/4153892 to your computer and use it in GitHub Desktop.
Gist to bypass all hover events for elements with .hover-bypass on touch devices
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
/* | |
* Usage: add class of .hover-bypass to all element with | |
* hover effects that aren't intended for touch | |
* users | |
* Credit: Something https://github.com/chrisblackburn wrote | |
*/ | |
/* Coffee */ | |
(($) -> | |
if typeof window.ontouchstart isnt "undefined" | |
$(".hover-bypass").live "mouseover", -> | |
$(this).click() | |
false | |
) jQuery | |
/* JS */ | |
(function($) { | |
if (typeof window.ontouchstart !== 'undefined') { | |
return $('.hover-bypass').live('mouseover', function() { | |
$(this).click(); | |
return false; | |
}); | |
} | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment