Merge branch 'dionysiusmarquis-dionysius-brach' into develop

# Conflicts:
#	src/dat/controllers/NumberControllerBox.js
#	src/dat/controllers/NumberControllerSlider.js
#	src/dat/controllers/factory.js
#	src/dat/gui/style.css
This commit is contained in:
Jeff Nusz 2016-08-17 16:16:15 -07:00
commit e129e08b9d
4 changed files with 15 additions and 3 deletions

View File

@ -29,15 +29,21 @@ const ControllerFactory = function(object, property) {
// Providing a map? // Providing a map?
if (common.isNumber(initialValue)) { if (common.isNumber(initialValue)) {
// Has min and max? (slider)
if (common.isNumber(arguments[2]) && common.isNumber(arguments[3])) { if (common.isNumber(arguments[2]) && common.isNumber(arguments[3])) {
// Has min and max. // has step?
if (common.isNumber(arguments[4])) { // has step if (common.isNumber(arguments[4])) {
return new NumberControllerSlider(object, property, arguments[2], arguments[3], arguments[4]); return new NumberControllerSlider(object, property, arguments[2], arguments[3], arguments[4]);
} }
return new NumberControllerSlider(object, property, arguments[2], arguments[3]); return new NumberControllerSlider(object, property, arguments[2], arguments[3]);
} }
return new NumberControllerBox(object, property, {min: arguments[2], max: arguments[3]});
// number box
if (common.isNumber(arguments[4])) { // has step
return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3], step: arguments[4] });
}
return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] });
} }
if (common.isString(initialValue)) { if (common.isString(initialValue)) {

View File

@ -65,6 +65,8 @@ class NumberControllerBox extends NumberController {
} }
function onMouseDrag(e) { function onMouseDrag(e) {
document.activeElement.blur();
const diff = prevY - e.clientY; const diff = prevY - e.clientY;
_this.setValue(_this.getValue() + diff * _this.__impliedStep); _this.setValue(_this.getValue() + diff * _this.__impliedStep);
@ -105,6 +107,7 @@ class NumberControllerBox extends NumberController {
} }
updateDisplay() { updateDisplay() {
if (dom.isActive(this.__input)) return null; // prevent number from update if user is trying to manually update
this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision); this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision);
return super.updateDisplay(); return super.updateDisplay();
} }

View File

@ -53,6 +53,8 @@ class NumberControllerSlider extends NumberController {
dom.addClass(this.__foreground, 'slider-fg'); dom.addClass(this.__foreground, 'slider-fg');
function onMouseDown(e) { function onMouseDown(e) {
document.activeElement.blur();
dom.bind(window, 'mousemove', onMouseDrag); dom.bind(window, 'mousemove', onMouseDrag);
dom.bind(window, 'mouseup', onMouseUp); dom.bind(window, 'mouseup', onMouseUp);

View File

@ -187,6 +187,7 @@ $input-color: lighten($background-color, 8.5%);
.slider-fg { .slider-fg {
background: $number-color; background: $number-color;
max-width: 100%;
} }
.slider:hover { .slider:hover {