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

CSS3 transformations #3

Open thepixelmonk opened 12 years ago

thepixelmonk commented 12 years ago

I'm trying to use this plugin on a bunch of elements that have been rotated (via css3's transform: rotate) and it seems to not play well. Any ideas?

gilmoreorless commented 12 years ago

Ooh, that's an interesting one.

At the moment the plugin is very much built around standard rectangular bounding boxes - to be honest the thought of rotations never occurred to me (though it really should have).

What's needed is a more robust method of getting the element's bounding box that takes all transforms (translate, skew, rotate) into account. element.getBoundingClientRect() is the most accurate solution when it works, but it doesn't have full cross-browser support for CSS transforms.