AshesOfOwls / jquery.shapeshift

A dynamic grid system with drag and drop functionality.
http://ashesofowls.github.com/jquery.shapeshift/
MIT License
1.67k stars 311 forks source link

Smoother Dragging: Proposed Change #94

Open austincondiff opened 10 years ago

austincondiff commented 10 years ago

I'd like to propose that you change lines 429 and 430 from this: selected_offset_y = $selected.outerHeight() / 2; return selected_offset_x = $selected.outerWidth() / 2;

to this: selected_offset_y = e.offsetY; return selected_offset_x = e.offsetX;

Dragging will seem more fluid because the element being dragged won't snap to the center to be dragged by the center of the object but rather will be dragged from the coordinates that you clicked the element.

Adventsparky commented 10 years ago

Have you tried this with a handle enabled?

In my tests e.offsetX and e.offsetY are both undefined

Edit: Actually even when I don't have the handle enabled, both are undefined

austincondiff commented 10 years ago

Works perfect for me. Hmm... why would they be undefined?

Adventsparky commented 10 years ago

I will look into it some more because this would be a nice tweak, didn't like the 'snap to the middle' effect going on, as the handles I have are in the top right of the elements so it was a bit of a jump.

Edit: So after a bit of searching, the issue is Firefox, Chrome has offsetX and Y just fine, they aren't consistently handled in different browsers though. There would need to be some extra calculation to try figure out the offset in Firefox and any other browser that didn't properly support it.

nhduong29 commented 9 years ago

Hi acondiff,

could you help me, How to enable drag in the position as identify(on top, on bottom...)

Thanks,