Skip to content

Commit 378c463

Browse files
committed
Fixing issue with onStop being called when not dragging
1 parent 1ff47f9 commit 378c463

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/draggable.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ module.exports = React.createClass({
154154

155155
getInitialState: function () {
156156
return {
157+
dragging: false,
157158
startX: 0, startY: 0,
158159
offsetX: 0, offsetY: 0,
159160
clientX: 0, clientY: 0
@@ -175,6 +176,7 @@ module.exports = React.createClass({
175176
}
176177

177178
this.setState({
179+
dragging: true,
178180
offsetX: e.clientX,
179181
offsetY: e.clientY,
180182
startX: parseInt(node.style.left, 10) || 0,
@@ -187,6 +189,14 @@ module.exports = React.createClass({
187189
},
188190

189191
handleMouseUp: function (e) {
192+
if (!this.state.dragging) {
193+
return;
194+
}
195+
196+
this.setState({
197+
dragging: false
198+
});
199+
190200
this.props.onStop(e, createUIEvent(this));
191201

192202
window.removeEventListener('mousemove', this.handleMouseMove);

0 commit comments

Comments
 (0)