Created
April 7, 2013 13:41
-
-
Save jhthorsen/5330541 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
$.fn.passThrough = function() { | |
this.hover( | |
function() { $(this).fadeTo('fast', 0.2); }, | |
function() { $(this).fadeTo('fast', 1.0); } | |
); | |
this.each(function() { | |
var self = this; | |
var last; | |
$(self).bind('click mousemove mouseout', function (e) { | |
var tmp = self.style.display || 'block'; | |
var under; | |
e.preventDefault(); | |
self.style.display = 'none'; | |
under = document.elementFromPoint(e.clientX, e.clientY); // could also be pageX, pageY..? | |
self.style.display = tmp; | |
if(under) { | |
if(e.type == 'mousemove' && last != under) { | |
if(last) $(last).trigger('mouseout'); | |
$(under).trigger('mouseover'); | |
last = under; | |
console.log(last); | |
} | |
else { | |
$(under).trigger(e.type); | |
} | |
} | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment