#6884 closed bug (fixed)
Draggable: ui.offset.left differs between the "start" and "drag" hooks
Reported by: | traviscooper | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.11.2 |
Component: | ui.draggable | Version: | 1.8.8 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
when using the 'ui.offset.left' value with the start, drag and stop events for DRAGGABLE, you get a different value range for the start event versus the drag and stop.
For example, the following output was generated by asking for the 'ui.position.left' and ui.offset.left' for each of the events listed (start, drag, stop), as I dragged the element 1px to the right.
Notice how on the [start] event, the ui.offset.left (ui.o.l value) is "645", but for the [drag] and [start] events, the values become exactly what the ui.position.left values are (ui.p.l).
[start]--ui.p.l(247)ui.o.l(645) [drag]--ui.p.l(248)ui.o.l(248) [stop]--ui.p.l(248)ui.o.l(248)
From my own calculations, the above output SHOULD be.
[start]--ui.p.l(247)ui.o.l(645) [drag]--ui.p.l(248)ui.o.l(646) [stop]--ui.p.l(248)ui.o.l(646)
Below is my code to reproduce.
$('.element_to_move').draggable({
containment: 'parent', cursor: 'pointer', scroll: true, axis: 'x' , grid: [1,0], start: function(event, ui) {
Update element data in Display $('#er2').append('[start]--ui.p.l('+ui.position.left+')ui.o.l('+ui.offset.left+')<br />');
}, drag: function(event, ui) {
Update element data in Display $('#er2').append('[drag]--ui.p.l('+ui.position.left+')ui.o.l('+ui.offset.left+')<br />');
}, stop: function(event, ui){
Update element data in Display $('#er2').append('[stop]--ui.p.l('+ui.position.left+')ui.o.l('+ui.offset.left+')<br />');
}
});
Change History (7)
comment:1 Changed 12 years ago by
comment:3 Changed 10 years ago by
Milestone: | 1.9.0 → 2.0.0 |
---|
comment:4 Changed 10 years ago by
Status: | new → open |
---|
New demo using latest: http://jsfiddle.net/48uVM/1/ which confirms the discrepancy. It looks to be on purpose and part of the internals: https://github.com/jquery/jquery-ui/blob/039ee746d3eaeeaa4ad92ecd8ebf4e6fcd11768c/ui/jquery.ui.draggable.js#L426
However, this is not ideal, and if the internals need to rely on the "position" values provided, they should be named appropriately to signify they aren't equivalent to the common notion of position and offset.
comment:5 Changed 10 years ago by
Summary: | ui.offset.left not correct values → Draggable: ui.offset.left differs between the "start" and "drag" hooks |
---|
comment:6 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Draggable: Recalculate hash offset on start after plugins run
Fixes #6884 Changeset: b5846bece34db31d69e75cb3a3537827c005910e
I'm thinking it shouldn't matter what the CSS positioning value is for the parent or element, since the initial value of the 'ui.offset.left' is correct.