diff --git a/core/field_angle.js b/core/field_angle.js index cd1138aec..7f521ec9d 100644 --- a/core/field_angle.js +++ b/core/field_angle.js @@ -264,16 +264,28 @@ Blockly.FieldAngle.prototype.onMouseMove = function(e) { } else if (dy > 0) { angle += 360; } + + // Do offsetting. if (Blockly.FieldAngle.CLOCKWISE) { angle = Blockly.FieldAngle.OFFSET + 360 - angle; } else { - angle -= Blockly.FieldAngle.OFFSET; + angle = 360 - (Blockly.FieldAngle.OFFSET - angle); } + if (angle > 360) { + angle -= 360; + } + + // Do rounding. if (Blockly.FieldAngle.ROUND) { angle = Math.round(angle / Blockly.FieldAngle.ROUND) * Blockly.FieldAngle.ROUND; } + // Do wrapping. + if (angle > Blockly.FieldAngle.WRAP) { + angle -= 360; + } + // Update value. var angleString = String(angle); if (angleString != this.text_) { @@ -295,6 +307,7 @@ Blockly.FieldAngle.prototype.updateGraph_ = function() { } // Always display the input (i.e. getText) even if it is invalid. var angleDegrees = Number(this.getText()) + Blockly.FieldAngle.OFFSET; + angleDegrees %= 360; var angleRadians = Blockly.utils.toRadians(angleDegrees); var path = ['M ', Blockly.FieldAngle.HALF, ',', Blockly.FieldAngle.HALF]; var x2 = Blockly.FieldAngle.HALF; @@ -334,7 +347,7 @@ Blockly.FieldAngle.prototype.doClassValidation_ = function(newValue) { return null; } var n = parseFloat(newValue || 0); - n = n % 360; + n %= 360; if (n < 0) { n += 360; } diff --git a/core/field_textinput.js b/core/field_textinput.js index 068a5ecc4..7e3e8e65f 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -396,7 +396,7 @@ Blockly.FieldTextInput.prototype.widgetDispose_ = function() { thisField.isBeingEdited_ = false; // No need to call setValue because if the widget is being closed the // latest input text has already been validated. - if (thisField.value_ != thisField.text_) { + if (thisField.value_ !== thisField.text_) { // At the end of an edit the text should be the same as the value. It // may not be if the input text is different than the validated text. // We should fix that.