Simple jQuery plugin to track the distance between an element and the mouse cursor.
Bind a listener to the update event like: $('.dropdown-toggle').vicinity().bind 'update', (e, distance) -> console.log distance
A distance of 0 means the mouse is on the element.
- target (defaults is document) You can set the target of the event listener to a different element than document. The event will only be triggered when the mouse hovers above that element.
If you just want to calculate the shortest distance between an element and a given point, you can use: $(el).distanceToPoint(x,y)
A nice way of using this is in combination with jquery.color, for instance:
$parent.css backgroundColor: $.Color('#fff').transition('#f00', ratio)
where the ratio is a value between 0.0 and 1.0 after dividing the distance by an arbitrary radius