Last active
December 14, 2015 15:19
-
-
Save Takazudo/5107255 to your computer and use it in GitHub Desktop.
This file contains 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
<style> | |
p span { | |
display: none; | |
} | |
.believablehover p:hover span { | |
display: inline; | |
} | |
</style> | |
<p><a href="/">Tap me</a><span>You tapped!</span></p> |
This file contains 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
var win8orhigher = (function() { | |
// windows browsers has str like "Windows NT 6.2" in its UA | |
// Win8 UAs' version is "6.2" | |
// browsers above this version may has touch events. | |
var ua = navigator.userAgent; | |
var matched = ua.match(/Windows NT ([\d\.]+)/); | |
if(!matched) { return false; } | |
var version = matched[1] * 1; | |
if(version < 6.2) { return false; } | |
return true; | |
}()); | |
Modernizr.believablehover = (function() { | |
if(win8orhigher) { return true; } // everything seems to be ok for Win8, maybe. | |
if(Modernizr.touch) { return false; } // every other touch devices does not need hover. | |
return true; // ah yes, I am a normal browser. | |
}()); | |
var cls = Modernizr.believablehover ? 'believablehover' : 'no-believablehover'; | |
$('html').addClass(cls); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment