gilmoreorless / jquery-nearest

Find the elements in a page that are closest to a particular point or element, based on pixel dimensions
http://gilmoreorless.github.io/jquery-nearest/
MIT License
98 stars 23 forks source link

Allow percentages for x/y/width/height options #2

Closed gilmoreorless closed 12 years ago

gilmoreorless commented 12 years ago

A suggestion was made to add helpers for testing the nearest element(s) to the top/bottom/left/right edges of the screen. The current workaround is to use arbitrary large values (e.g. {x: 0, h: 999999} for the left edge).

What would be better is allowing percentage values, that equate to a percentage of the page's width/height, so the above example could be {x: 0, h: '100%'}

This could also allow shortcuts like {x: '50%', y: '50%'} for the centre of the page.

gilmoreorless commented 12 years ago

Added support for percentage strings in version 1.2. A demo is at http://gilmoreorless.github.com/jquery-nearest/demo-edges.html