Closed chanpory closed 9 years ago
At the moment there's no built-in way to do that.
As a workaround, perhaps you could pre-process the elements above your example 400px mark to add a special class
to them, then use that class as the selector to the call to nearest
.
That's just a suggestion off the top of my head, but obviously I don't know if it will work for your use case.
Thanks, I'll try to figure something out. As a feature request, it'd be great to specify a region relative to the origin point for $.nearest to look in when getting elements. Something like:
var closestElements = $.nearest({x: e.pageX, y: e.pageY, constrainTo:"above" }, $('div'));
Hello. Thanks a lot for this plugin. :)
Same thing here, it would be perfect to set a direction to get the nearest object. "above", "below", "right", "left".
For example I need to achieve a keyboard navigation. Pressing Right arrow goes the nearest element to the right of the current element. Pressing Up arrow goes to the nearest element above the current element, etc...
Thanks to @dogoku this is now available with the directionConstraints
option in 1.4.0.
In other words, how do I ignore everything below the origin point? For example, if my mouse's Y position is 400px, I'd like to get the nearest element that is above it.