From 689560b1428ff8d5a66f437bd59504306b6693f5 Mon Sep 17 00:00:00 2001 From: Vousk-prod Date: Thu, 5 Nov 2015 23:00:09 +0100 Subject: [PATCH] Added in the NumberControllerSlider a reference to the NumberControllerBox associated, to fix the displayed value precision bug for sliders when step is defined afterwards (via step() method instead of as option in add() method) --- src/dat/controllers/NumberController.js | 5 +++++ src/dat/gui/GUI.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/dat/controllers/NumberController.js b/src/dat/controllers/NumberController.js index 4cab081..6c25dee 100644 --- a/src/dat/controllers/NumberController.js +++ b/src/dat/controllers/NumberController.js @@ -124,6 +124,11 @@ define([ this.__step = v; this.__impliedStep = v; this.__precision = numDecimals(v); + if (this.__valueControllerBox !== undefined) { + this.__valueControllerBox.__step = this.__step; + this.__valueControllerBox.__impliedStep = this.__impliedStep; + this.__valueControllerBox.__precision = this.__precision; + } return this; } diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index b0f61d3..649c57b 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -927,6 +927,8 @@ define([ var box = new NumberControllerBox(controller.object, controller.property, { min: controller.__min, max: controller.__max, step: controller.__step }); + controller.__valueControllerBox = box; + common.each(['updateDisplay', 'onChange', 'onFinishChange'], function(method) { var pc = controller[method]; var pb = box[method];