Migrate core/utils/rect.js to goog.module

This commit is contained in:
kozbial
2021-07-14 13:56:18 -07:00
committed by Monica Kozbial
parent 0ac3994343
commit 466a0db809
2 changed files with 8 additions and 5 deletions

View File

@@ -16,7 +16,8 @@
* @name Blockly.utils.Rect
* @namespace
*/
goog.provide('Blockly.utils.Rect');
goog.module('Blockly.utils.Rect');
goog.module.declareLegacyNamespace();
/**
@@ -28,7 +29,7 @@ goog.provide('Blockly.utils.Rect');
* @struct
* @constructor
*/
Blockly.utils.Rect = function(top, bottom, left, right) {
const Rect = function(top, bottom, left, right) {
/** @type {number} */
this.top = top;
@@ -49,7 +50,7 @@ Blockly.utils.Rect = function(top, bottom, left, right) {
* @param {number} y The y coordinate to test for containment.
* @return {boolean} Whether this rectangle contains given coordinate.
*/
Blockly.utils.Rect.prototype.contains = function(x, y) {
Rect.prototype.contains = function(x, y) {
return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
};
@@ -60,7 +61,9 @@ Blockly.utils.Rect.prototype.contains = function(x, y) {
* intersection with.
* @return {boolean} Whether this rectangle intersects the provided rectangle.
*/
Blockly.utils.Rect.prototype.intersects = function(other) {
Rect.prototype.intersects = function(other) {
return !(this.left > other.right || this.right < other.left ||
this.top > other.bottom || this.bottom < other.top);
};
exports = Rect;

View File

@@ -180,7 +180,7 @@ goog.addDependency('../../core/utils/keycodes.js', ['Blockly.utils.KeyCodes'], [
goog.addDependency('../../core/utils/math.js', ['Blockly.utils.math'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/utils/metrics.js', ['Blockly.utils.Metrics'], []);
goog.addDependency('../../core/utils/object.js', ['Blockly.utils.object'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/utils/rect.js', ['Blockly.utils.Rect'], []);
goog.addDependency('../../core/utils/rect.js', ['Blockly.utils.Rect'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/utils/size.js', ['Blockly.utils.Size'], []);
goog.addDependency('../../core/utils/string.js', ['Blockly.utils.string'], []);
goog.addDependency('../../core/utils/style.js', ['Blockly.utils.style'], ['Blockly.utils.Coordinate', 'Blockly.utils.Size']);