I want to have an element B following element A when A is dragged. I use draggable from jQueryUI.
I made this:
http://jsfiddle.net/7KhSS/
It works, but isn’t really accurate. While B is following A, ther often is a 1px-3px gap either horizontally or vertically.
I can’t nest element B inside element A (which would solve the current problem), because in my case, element B has fixed positioning.
Instead of using
$(this).position()using the offset property on the ui object that is passed in as the second parameter to the event:http://jsfiddle.net/7KhSS/3/