Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger an event when the mouse hits the bottom of the page

I am trying to implement a menu bar that works similarly to the windows task bar. One of property that I want to emulate is hide/show when the mouse goes in the bottom of the page. How can I detect when the mouse is in the bottom of the page?

First of all, is there a plugin for JQuery or similar libraries which already implement this action?

A possible solution is to use a invisible div in the bottom which triggers the event when the mouse gets in. I was wondering if there is a better solution than this.

like image 558
Giuseppe Pes Avatar asked Dec 15 '25 01:12

Giuseppe Pes


1 Answers

If using jQuery is not a problem

window.onmousemove= function(e){
 if(e.y>= $(document).height()-10)
    alert('you did hit the bottom!');
}

Will do. check this Fiddle

note: i've given a 10px breathing space

Update: Fiddle with a taskbar like div - Updated Fiddle

like image 59
T J Avatar answered Dec 16 '25 18:12

T J



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!