views:

168

answers:

1

I'm trying to determine if the mouse is over an element preferably with YUI if there is a method for that already.

Basically something like

function bool IsMouseOver(Element);

A: 

I ended up checking it myself.

I have the region from the target element

var region = YAHOO.util.Dom.getRegion(this.element);
var top = region.top;
var left = region.left;
var bottom = region.bottom;
var right = region.right;

Then the mouse coordinates

var mouseXY = YAHOO.util.Event.getXY(e);
var mX = mouseXY[0];
var mY = mouseXY[1];

And then a simple if statement to check if the mouse coordinates were in the region

(mX > left && mX < right && mY > top && mY < bottom)
Chad