Determining if the mouse position is near the edges of the browser

In the browser, I am trying to determine if the point representing the position of the mouse is in what I call the "outer area". For example, in an attached image, the outer area is the area with a blue background.

alt text

In the code and image, W represents the width of the browser viewing area, while H represents the height and x, y for the mouse position

Right now I am using this piece of code to do this:

if (((x>0 && x<w1) || (x>w2 && x<W))
    ||
    ((x>w1 && x<w2) &&
      ((y>0 && y<h1) || (y>h2 && y<H))
    ))
    console.log("we are in the outer area")

While it works as is, I wonder if there is a better way to do this?

+5
source share
2 answers

, 0 W, x 0 W. Y. :

if((x>w2 || x<w1) || (y>h2 || y<h1)){
  console.log("We are in the outer area");
}
+5

DIV ( outer), hover.

+4

All Articles