diff --git a/dist/es2015/UI.js b/dist/es2015/UI.js index 358c989f..a7403934 100644 --- a/dist/es2015/UI.js +++ b/dist/es2015/UI.js @@ -199,6 +199,8 @@ export class UIDragger extends UIButton { this._moveHoldID = -1; if (states.dragging === undefined) this._states['dragging'] = false; + if (states.moved === undefined) + this._states['moved'] = false; if (states.offset === undefined) this._states['offset'] = new Pt(); const UA = UIPointerActions; @@ -209,6 +211,7 @@ export class UIDragger extends UIButton { this._draggingID = this.on(UA.move, (t, p) => { if (this.state('dragging')) { UI._trigger(this._actions[UA.uidrag], t, p, UA.uidrag); + this.state('moved', true); } }); }); @@ -216,7 +219,10 @@ export class UIDragger extends UIButton { this.state('dragging', false); this.off(UA.move, this._draggingID); this.unhold(this._moveHoldID); - UI._trigger(this._actions[UA.drop], target, pt, type); + if (this.state('moved')) { + UI._trigger(this._actions[UA.drop], target, pt, type); + this.state('moved', false); + } }); } onDrag(fn) { diff --git a/dist/es5.js b/dist/es5.js index 85c64ec9..f63ea5cd 100644 --- a/dist/es5.js +++ b/dist/es5.js @@ -8177,6 +8177,7 @@ var UIDragger = function (_UIButton) { _this2._draggingID = -1; _this2._moveHoldID = -1; if (states.dragging === undefined) _this2._states['dragging'] = false; + if (states.moved === undefined) _this2._states['moved'] = false; if (states.offset === undefined) _this2._states['offset'] = new Pt_1.Pt(); var UA = exports.UIPointerActions; _this2.on(UA.down, function (target, pt, type) { @@ -8186,6 +8187,7 @@ var UIDragger = function (_UIButton) { _this2._draggingID = _this2.on(UA.move, function (t, p) { if (_this2.state('dragging')) { UI._trigger(_this2._actions[UA.uidrag], t, p, UA.uidrag); + _this2.state('moved', true); } }); }); @@ -8193,7 +8195,10 @@ var UIDragger = function (_UIButton) { _this2.state('dragging', false); _this2.off(UA.move, _this2._draggingID); _this2.unhold(_this2._moveHoldID); - UI._trigger(_this2._actions[UA.drop], target, pt, type); + if (_this2.state('moved')) { + UI._trigger(_this2._actions[UA.drop], target, pt, type); + _this2.state('moved', false); + } }); return _this2; } diff --git a/dist/index.js b/dist/index.js index 16adc0e9..36e3567c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5572,6 +5572,8 @@ class UIDragger extends UIButton { this._moveHoldID = -1; if (states.dragging === undefined) this._states['dragging'] = false; + if (states.moved === undefined) + this._states['moved'] = false; if (states.offset === undefined) this._states['offset'] = new Pt_1.Pt(); const UA = exports.UIPointerActions; @@ -5582,6 +5584,7 @@ class UIDragger extends UIButton { this._draggingID = this.on(UA.move, (t, p) => { if (this.state('dragging')) { UI._trigger(this._actions[UA.uidrag], t, p, UA.uidrag); + this.state('moved', true); } }); }); @@ -5589,7 +5592,10 @@ class UIDragger extends UIButton { this.state('dragging', false); this.off(UA.move, this._draggingID); this.unhold(this._moveHoldID); - UI._trigger(this._actions[UA.drop], target, pt, type); + if (this.state('moved')) { + UI._trigger(this._actions[UA.drop], target, pt, type); + this.state('moved', false); + } }); } onDrag(fn) { diff --git a/dist/pts.js b/dist/pts.js index 97914805..9e8227eb 100644 --- a/dist/pts.js +++ b/dist/pts.js @@ -5572,6 +5572,8 @@ class UIDragger extends UIButton { this._moveHoldID = -1; if (states.dragging === undefined) this._states['dragging'] = false; + if (states.moved === undefined) + this._states['moved'] = false; if (states.offset === undefined) this._states['offset'] = new Pt_1.Pt(); const UA = exports.UIPointerActions; @@ -5582,6 +5584,7 @@ class UIDragger extends UIButton { this._draggingID = this.on(UA.move, (t, p) => { if (this.state('dragging')) { UI._trigger(this._actions[UA.uidrag], t, p, UA.uidrag); + this.state('moved', true); } }); }); @@ -5589,7 +5592,10 @@ class UIDragger extends UIButton { this.state('dragging', false); this.off(UA.move, this._draggingID); this.unhold(this._moveHoldID); - UI._trigger(this._actions[UA.drop], target, pt, type); + if (this.state('moved')) { + UI._trigger(this._actions[UA.drop], target, pt, type); + this.state('moved', false); + } }); } onDrag(fn) { diff --git a/src/UI.ts b/src/UI.ts index e56bff7c..2e5adce1 100644 --- a/src/UI.ts +++ b/src/UI.ts @@ -420,6 +420,7 @@ export class UIDragger extends UIButton { constructor( group:GroupLike, shape:string, states:{[key:string]: any}={}, id?:string ) { super( group, shape, states, id ); if (states.dragging === undefined) this._states['dragging'] = false; + if (states.moved === undefined) this._states['moved'] = false; if (states.offset === undefined) this._states['offset'] = new Pt(); const UA = UIPointerActions; @@ -434,6 +435,7 @@ export class UIDragger extends UIButton { this._draggingID = this.on( UA.move, (t:UI, p:PtLike) => { if ( this.state('dragging') ) { UI._trigger( this._actions[UA.uidrag], t, p, UA.uidrag ); + this.state( 'moved', true ); } }); }); @@ -443,7 +445,10 @@ export class UIDragger extends UIButton { this.state('dragging', false); this.off(UA.move, this._draggingID); // remove 'all' listener this.unhold( this._moveHoldID ); // // stop keeping hold of move - UI._trigger( this._actions[UA.drop], target, pt, type ); + if ( this.state('moved') ) { + UI._trigger( this._actions[UA.drop], target, pt, type ); + this.state( 'moved', false ); + } }); }