Skip to content

Commit 72cab9c

Browse files
committed
Calculate bounds *before* firing events
1 parent 6163ad2 commit 72cab9c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/Draggable.es6

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ export default class Draggable extends DraggableCore {
167167

168168
let uiEvent = createUIEvent(this, coreEvent);
169169

170-
// Short-circuit if user's callback killed it.
171-
let shouldUpdate = this.props.onDrag(e, uiEvent);
172-
if (shouldUpdate === false) return false;
173-
174170
let newState = {
175171
clientX: uiEvent.position.left,
176172
clientY: uiEvent.position.top
@@ -193,8 +189,16 @@ export default class Draggable extends DraggableCore {
193189
// Recalculate slack by noting how much was shaved by the boundPosition handler.
194190
newState.slackX = this.state.slackX + (clientX - newState.clientX);
195191
newState.slackY = this.state.slackY + (clientY - newState.clientY);
192+
193+
// Update the event we fire.
194+
uiEvent.position.left = clientX;
195+
uiEvent.position.top = clientY;
196196
}
197197

198+
// Short-circuit if user's callback killed it.
199+
let shouldUpdate = this.props.onDrag(e, uiEvent);
200+
if (shouldUpdate === false) return false;
201+
198202
this.setState(newState);
199203
};
200204

0 commit comments

Comments
 (0)