Skip to content

Instantly share code, notes, and snippets.

@smhmic
Created March 24, 2014 16:58
Show Gist options
  • Save smhmic/9744414 to your computer and use it in GitHub Desktop.
Save smhmic/9744414 to your computer and use it in GitHub Desktop.
disable :hover on touch devices to avoid sticky hover state (http://retrogamecrunch.com/tmp/hover-fix)
// disable :hover on touch devices
// based on https://gist.github.com/4404503
// via https://twitter.com/javan/status/284873379062890496
// + https://twitter.com/pennig/status/285790598642946048
// re http://retrogamecrunch.com/tmp/hover
if ('createTouch' in document)
{
try
{
var ignore = /:hover/;
for (var i=0; i<document.styleSheets.length; i++)
{
var sheet = document.styleSheets[i];
for (var j=sheet.cssRules.length-1; j>=0; j--)
{
var rule = sheet.cssRules[j];
if (rule.type === CSSRule.STYLE_RULE && ignore.test(rule.selectorText))
{
sheet.deleteRule(j);
}
}
}
}
catch(e){}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment