From af02b71d6aa5dfe0953a431ab68aa87aba9b2e3b Mon Sep 17 00:00:00 2001 From: Andrej Date: Sun, 3 Feb 2019 13:06:35 +0700 Subject: [PATCH] NumberController Step is working properly See details about issue in https://github.com/dataarts/dat.gui/issues/48#issuecomment-460026017 --- src/dat/controllers/NumberController.js | 2 +- src/dat/controllers/NumberControllerBox.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dat/controllers/NumberController.js b/src/dat/controllers/NumberController.js index 664191a..3f2c1bb 100644 --- a/src/dat/controllers/NumberController.js +++ b/src/dat/controllers/NumberController.js @@ -68,7 +68,7 @@ class NumberController extends Controller { _v = this.__max; } - if (this.__step !== undefined && _v % this.__step !== 0) { + if (this.__step !== undefined && this.__step !== 0 && _v % this.__step !== 0) { _v = Math.round(_v / this.__step) * this.__step; } diff --git a/src/dat/controllers/NumberControllerBox.js b/src/dat/controllers/NumberControllerBox.js index 462ebf2..c589c90 100644 --- a/src/dat/controllers/NumberControllerBox.js +++ b/src/dat/controllers/NumberControllerBox.js @@ -108,7 +108,7 @@ class NumberControllerBox extends NumberController { } updateDisplay() { - this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision); + this.__input.value = this.__truncationSuspended || this.__step === 0 ? this.getValue() : roundToDecimal(this.getValue(), this.__precision); return super.updateDisplay(); } }