From 08a3e8f670241a46fd95c0694acf34fdcb00e14f Mon Sep 17 00:00:00 2001 From: Jeff Nusz Date: Mon, 14 Nov 2016 11:13:28 -0800 Subject: [PATCH] onFinish no longer fires during mouse drag of number control. fixes #112 --- src/dat/controllers/NumberControllerBox.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dat/controllers/NumberControllerBox.js b/src/dat/controllers/NumberControllerBox.js index d0cc3c6..edc2761 100644 --- a/src/dat/controllers/NumberControllerBox.js +++ b/src/dat/controllers/NumberControllerBox.js @@ -57,14 +57,18 @@ class NumberControllerBox extends NumberController { } } - function onBlur() { - onChange(); + function onFinish() { if (_this.__onFinishChange) { _this.__onFinishChange.call(_this, _this.getValue()); } } + function onBlur() { + onChange(); + } + function onMouseDrag(e) { + // TODO.. why do we need to blur to update input value? document.activeElement.blur(); const diff = prevY - e.clientY; @@ -76,6 +80,7 @@ class NumberControllerBox extends NumberController { function onMouseUp() { dom.unbind(window, 'mousemove', onMouseDrag); dom.unbind(window, 'mouseup', onMouseUp); + onFinish(); } function onMouseDown(e) { @@ -93,11 +98,12 @@ class NumberControllerBox extends NumberController { dom.bind(this.__input, 'blur', onBlur); dom.bind(this.__input, 'mousedown', onMouseDown); dom.bind(this.__input, 'keydown', function(e) { - // When pressing entire, you can be as precise as you want. + // When pressing enter, you can be as precise as you want. if (e.keyCode === 13) { _this.__truncationSuspended = true; this.blur(); _this.__truncationSuspended = false; + onFinish(); } });