ded / bonzo

library agnostic, extensible DOM utility
Other
1.32k stars 137 forks source link

Add position() #82

Open enyo opened 12 years ago

enyo commented 12 years ago

EDIT

Is there any specific reason to why the function offset() is called like that, and not position(), like in jQuery?

Since offsetLeft, etc.. all measure the offset to their next offsetParent, it seams kind of strange to have offset() return the position in the browser window...

Ok.. I'm sorry, I confused the jQuery functions. It's just that position() is missing from bonzos toolkit.

ded commented 12 years ago

the goal of most of my core Ender modules was to reduce the cruft that you didn't need in jQuery. getting an offsetTop from an offsetParent is simple, so I didn't include it. but in either case, are you running into a real issue with it being named offset()? I preferred the name over position

enyo commented 12 years ago

Well.. I think that jQuery's naming convention is a bit strange here... if offsetLeft in an element is the position from an offsetParent then I would assume that offset() returns the offsets, not position(). Also: offsetLeft doesn't work as expected in IE6 + IE7, so jQuery handles that for you (but I really don't need that support.. just saying that it makes sense to wrap it).

Getting the right offsets (inside offsetParent) in inline elements is also not that obvious...

enyo commented 12 years ago

Also: Webkit has a very weird offset bug if an offsetParent is inline: http://jsfiddle.net/enyo/uDeZ9/ (Test it in Webkit and FF / Opera)