Ok, my question is simple, though I am unsure if the answer will be. I have an element that is fixed to the bottom of the browser window. When it is unneeded I want to hide it(set height to 0px). When the user’s mouse is X units away from the bottom of the WINDOW (not document) I want to show the div again. I googled a bit and all I could find was information on triggering events/preforming actions when the page was scrolled to X units away from the bottom. I need not the exact code of how to do this, if I could just be pointed into the right direction.
The question(for those that didn’t see it):
How to fire an event/execute a function when the mouse pointer is within X units from the bottom of the browser window(not document)?
A few notes:
This is for a greasemonkey/userscript so answers need not apply to IE.
Please do not suggest the usage of a library. For something as small as this, requiring an entire library is not an answer I am willing to accept.
ANSWER:
Building off of Kir lvlev’s answer below(Remember to give his answer an upvote):
// Standards compliant browsers
// if you have an IE solution, post it in the comments and I will add it.
window.addEventListener("mousemove",function(e) {
// 20 is the number of pixels from the bottom inwhich the action should be preformed
if ((this.innerHeight - 20) <= e.clientY) {
//do stuff
}
});
use mousemove event handler
non-jquery: