From 303cb10e0715fc41314da1f20b9758f18d7b46d9 Mon Sep 17 00:00:00 2001 From: Dennis Markgraf Date: Sat, 19 Jul 2014 13:51:57 +0200 Subject: [PATCH 1/2] fixes missing step argument step argument was not provided in factory.js --- src/dat/controllers/factory.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dat/controllers/factory.js b/src/dat/controllers/factory.js index 897b267..0c10548 100644 --- a/src/dat/controllers/factory.js +++ b/src/dat/controllers/factory.js @@ -37,12 +37,18 @@ define([ if (common.isNumber(arguments[2]) && common.isNumber(arguments[3])) { - // Has min and max. - return new NumberControllerSlider(object, property, arguments[2], arguments[3]); + // Has min and max. + if (common.isNumber(arguments[4])) // has step + return new NumberControllerSlider(object, property, arguments[2], arguments[3], arguments[4]); + else + return new NumberControllerSlider(object, property, arguments[2], arguments[3]); } else { - return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] }); + if (common.isNumber(arguments[4])) + return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3], step: arguments[4] }); + else + return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] }); } From b94ff75f35f6bff9fd4a44bf1a0569cedb1a8e39 Mon Sep 17 00:00:00 2001 From: Dennis Markgraf Date: Sat, 19 Jul 2014 14:15:35 +0200 Subject: [PATCH 2/2] Number Controllers Improvements adds the ability to change the value in the Number box while the controller is listening via .listen(). Prevents the slider bar from being wider than than 100%. --- src/dat/controllers/NumberControllerBox.js | 6 ++++-- src/dat/controllers/NumberControllerSlider.js | 4 +++- src/dat/gui/style.css | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dat/controllers/NumberControllerBox.js b/src/dat/controllers/NumberControllerBox.js index 6ae574d..a6dd97f 100644 --- a/src/dat/controllers/NumberControllerBox.js +++ b/src/dat/controllers/NumberControllerBox.js @@ -85,7 +85,9 @@ define([ } function onMouseDrag(e) { - + + document.activeElement.blur(); + var diff = prev_y - e.clientY; _this.setValue(_this.getValue() + diff * _this.__impliedStep); @@ -114,7 +116,7 @@ define([ { updateDisplay: function() { - + if (dom.isActive(this.__input)) return; this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision); return NumberControllerBox.superclass.prototype.updateDisplay.call(this); } diff --git a/src/dat/controllers/NumberControllerSlider.js b/src/dat/controllers/NumberControllerSlider.js index 6794008..0de5c93 100644 --- a/src/dat/controllers/NumberControllerSlider.js +++ b/src/dat/controllers/NumberControllerSlider.js @@ -55,7 +55,9 @@ function(NumberController, dom, css, common, styleSheet) { dom.addClass(this.__foreground, 'slider-fg'); function onMouseDown(e) { - + + document.activeElement.blur(); + dom.bind(window, 'mousemove', onMouseDrag); dom.bind(window, 'mouseup', onMouseUp); diff --git a/src/dat/gui/style.css b/src/dat/gui/style.css index e53790d..5d7a400 100644 --- a/src/dat/gui/style.css +++ b/src/dat/gui/style.css @@ -273,7 +273,8 @@ background: #303030; cursor: ew-resize; } .dg .c .slider-fg { - background: #2fa1d6; } + background: #2fa1d6; + max-width: 100%; } .dg .c .slider:hover { background: #3c3c3c; } .dg .c .slider:hover .slider-fg {