diff --git a/src/BooleanController.js b/src/BooleanController.js index 22a276e..bb1fc0c 100644 --- a/src/BooleanController.js +++ b/src/BooleanController.js @@ -14,7 +14,6 @@ export default class BooleanController extends Controller { this.$input.addEventListener( 'change', () => { this.setValue( this.$input.checked ); - this._callOnFinishChange(); } ); this.$disable = this.$input; diff --git a/src/Controller.js b/src/Controller.js index 2aaf0d2..e1f502b 100644 --- a/src/Controller.js +++ b/src/Controller.js @@ -200,7 +200,6 @@ export default class Controller { */ reset() { this.setValue( this.initialValue ); - this._callOnFinishChange(); return this; } @@ -401,12 +400,15 @@ export default class Controller { * @param {any} value * @returns {this} */ - setValue( value ) { + setValue( value, finishChange = true ) { if ( this.getValue() !== value ) { this.object[ this.property ] = value; this._callOnChange(); + if ( finishChange ) { + this._callOnFinishChange(); + } this.updateDisplay(); } @@ -426,7 +428,6 @@ export default class Controller { load( value ) { this.setValue( value ); - this._callOnFinishChange(); return this; } diff --git a/src/NumberController.js b/src/NumberController.js index 530a03a..08c39ff 100644 --- a/src/NumberController.js +++ b/src/NumberController.js @@ -95,7 +95,7 @@ export default class NumberController extends Controller { value = this._snap( value ); } - this.setValue( this._clamp( value ) ); + this.setValue( this._clamp( value ), false ); }; @@ -108,7 +108,7 @@ export default class NumberController extends Controller { if ( isNaN( value ) ) return; - this._snapClampSetValue( value + delta ); + this._snapClampSetValue( value + delta, false ); // Force the input to updateDisplay when it's focused this.$input.value = this.getValue(); @@ -202,7 +202,7 @@ export default class NumberController extends Controller { dragDelta = this._min - initValue; } - this._snapClampSetValue( initValue + dragDelta ); + this._snapClampSetValue( initValue + dragDelta, false ); } @@ -226,8 +226,8 @@ export default class NumberController extends Controller { const onBlur = () => { this._inputFocused = false; - this.updateDisplay(); this._callOnFinishChange(); + this.updateDisplay(); }; this.$input.addEventListener( 'input', onInput ); @@ -267,7 +267,7 @@ export default class NumberController extends Controller { const setValueFromX = clientX => { const rect = this.$slider.getBoundingClientRect(); let value = map( clientX, rect.left, rect.right, this._min, this._max ); - this._snapClampSetValue( value ); + this._snapClampSetValue( value, false ); }; // Mouse drag @@ -382,7 +382,7 @@ export default class NumberController extends Controller { // set value const delta = this._normalizeMouseWheel( e ) * this._step; - this._snapClampSetValue( this.getValue() + delta ); + this._snapClampSetValue( this.getValue() + delta, false ); // force the input to updateDisplay when it's focused this.$input.value = this.getValue(); @@ -498,8 +498,8 @@ export default class NumberController extends Controller { return value; } - _snapClampSetValue( value ) { - this.setValue( this._clamp( this._snap( value ) ) ); + _snapClampSetValue( value, finishChange = true ) { + this.setValue( this._clamp( this._snap( value ) ), finishChange ); } get _hasScrollBar() { diff --git a/src/OptionController.js b/src/OptionController.js index 26548d1..a3d5298 100644 --- a/src/OptionController.js +++ b/src/OptionController.js @@ -14,7 +14,6 @@ export default class OptionController extends Controller { this.$select.addEventListener( 'change', () => { this.setValue( this._values[ this.$select.selectedIndex ] ); - this._callOnFinishChange(); } ); this.$select.addEventListener( 'focus', () => { diff --git a/src/StringController.js b/src/StringController.js index f17d958..a67641b 100644 --- a/src/StringController.js +++ b/src/StringController.js @@ -12,7 +12,7 @@ export default class StringController extends Controller { this.$input.setAttribute( 'aria-labelledby', this.$name.id ); this.$input.addEventListener( 'input', () => { - this.setValue( this.$input.value ); + this.setValue( this.$input.value, false ); } ); this.$input.addEventListener( 'keydown', e => {