From 2f99729905a733df7c39acd1ae0216b28c97282b Mon Sep 17 00:00:00 2001 From: David Back Date: Mon, 7 Jan 2019 11:31:04 -0800 Subject: [PATCH] add rect case, fix step rounding --- scripts/system/html/js/draggableNumber.js | 7 ++- scripts/system/html/js/entityProperties.js | 53 +++++++++++++++------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/scripts/system/html/js/draggableNumber.js b/scripts/system/html/js/draggableNumber.js index b1039ed37b..b63b6e4688 100644 --- a/scripts/system/html/js/draggableNumber.js +++ b/scripts/system/html/js/draggableNumber.js @@ -106,7 +106,7 @@ DraggableNumber.prototype = { stepUp: function() { if (!this.isDisabled()) { - this.elInput.stepUp(); + this.elInput.value = parseFloat(this.elInput.value) + this.step; this.inputChange(); if (this.valueChangeFunction) { this.valueChangeFunction(); @@ -116,7 +116,7 @@ DraggableNumber.prototype = { stepDown: function() { if (!this.isDisabled()) { - this.elInput.stepDown(); + this.elInput.value = parseFloat(this.elInput.value) - this.step; this.inputChange(); if (this.valueChangeFunction) { this.valueChangeFunction(); @@ -139,6 +139,7 @@ DraggableNumber.prototype = { }, inputChange: function() { + console.log("DBACK TEST inputChange1 elInput " + this.elInput.value + " elText " + this.elText.firstChild.data + " min " + this.min + " max " + this.max + " step " + this.step); let value = this.elInput.value; if (this.max !== undefined) { value = Math.min(this.max, value); @@ -146,7 +147,9 @@ DraggableNumber.prototype = { if (this.min !== undefined) { value = Math.max(this.min, value); } + console.log("DBACK TEST inputChange2 elInput " + this.elInput.value + " elText " + this.elText.firstChild.data + " min " + this.min + " max " + this.max + " step " + this.step); this.setValue(value); + console.log("DBACK TEST inputChange3 elInput " + this.elInput.value + " elText " + this.elText.firstChild.data + " min " + this.min + " max " + this.max + " step " + this.step); }, inputBlur: function(ev) { diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index a6c9bde84d..2a1e4d0a4e 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -1947,13 +1947,14 @@ function createNumberProperty(property, elProperty) { } function updateNumberMinMax(property) { - let propertyData = property.data; let elInput = property.elInput; - if (propertyData.min !== undefined) { - elInput.setAttribute("min", propertyData.min); + let min = property.data.min; + let max = property.data.max; + if (min !== undefined) { + elInput.setAttribute("min", min); } - if (propertyData.max !== undefined) { - elInput.setAttribute("max", propertyData.max); + if (max !== undefined) { + elInput.setAttribute("max", max); } } @@ -2029,6 +2030,15 @@ function createRectProperty(property, elProperty) { return elResult; } +function updateRectMinMax(property) { + let min = property.data.min; + let max = property.data.max; + property.elNumberX.updateMinMax(min, max); + property.elNumberY.updateMinMax(min, max); + property.elNumberWidth.updateMinMax(min, max); + property.elNumberHeight.updateMinMax(min, max); +} + function createVec3Property(property, elProperty) { let propertyData = property.data; @@ -2079,11 +2089,12 @@ function createVec2Property(property, elProperty) { } function updateVectorMinMax(property) { - let propertyData = property.data; - property.elNumberX.updateMinMax(propertyData.min, propertyData.max); - property.elNumberY.updateMinMax(propertyData.min, propertyData.max); + let min = property.data.min; + let max = property.data.max; + property.elNumberX.updateMinMax(min, max); + property.elNumberY.updateMinMax(min, max); if (property.elNumberZ) { - property.elNumberZ.updateMinMax(propertyData.min, propertyData.max); + property.elNumberZ.updateMinMax(min, max); } } @@ -3094,7 +3105,7 @@ function loaded() { properties[propertyID] = property; } if (propertyData.type === 'number' || propertyData.type === 'number-draggable' || - propertyData.type === 'vec2' || propertyData.type === 'vec3') { + propertyData.type === 'vec2' || propertyData.type === 'vec3' || propertyData.type === 'rect') { propertyRangeRequests.push(propertyID); } @@ -3473,13 +3484,21 @@ function loaded() { propertyData.max /= multiplier; } } - if (propertyData.type === 'number') { - updateNumberMinMax(properties[property]); - } else if (propertyData.type === 'number-draggable') { - updateNumberDraggableMinMax(properties[property]); - } else if (propertyData.type === 'vec2' || propertyData.type === 'vec3') { - updateVectorMinMax(properties[property]); - } + switch (propertyData.type) { + case 'number': + updateNumberMinMax(properties[property]); + break; + case 'number-draggable': + updateNumberDraggableMinMax(properties[property]); + break; + case 'vec3': + case 'vec2': + updateVectorMinMax(properties[property]); + break; + case 'rect': + updateRectMinMax(properties[property]); + break; + } } } }