Files
blockly/core/utils/size.js
Rachel Fenichel 9d8eeb30f6 refactor: convert some files to es6 classes (#5861)
* refactor: convert utils/coordinate.js to ES6 class

* refactor: convert utils/rect.js to ES6 class

* refactor: convert utils/size.js to ES6 class

* refactor: convert block_drag_surface.js to ES6 class

* refactor: convert block_dragger.js to ES6 class

* refactor: convert bubble_dragger.js to ES6 class

* chore: declare bubble property in the constructor

* refactor: convert bubble.js to ES6 class

* chore: clang-format

* chore(lint): lint and format
2022-01-07 14:49:49 -08:00

66 lines
1.3 KiB
JavaScript

/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Utility methods for size calculation.
* These methods are not specific to Blockly, and could be factored out into
* a JavaScript framework such as Closure.
*/
'use strict';
/**
* Utility methods for size calculation.
* These methods are not specific to Blockly, and could be factored out into
* a JavaScript framework such as Closure.
* @class
*/
goog.module('Blockly.utils.Size');
/**
* Class for representing sizes consisting of a width and height.
*/
const Size = class {
/**
* @param {number} width Width.
* @param {number} height Height.
* @struct
* @alias Blockly.utils.Size
*/
constructor(width, height) {
/**
* Width
* @type {number}
*/
this.width = width;
/**
* Height
* @type {number}
*/
this.height = height;
}
/**
* Compares sizes for equality.
* @param {?Size} a A Size.
* @param {?Size} b A Size.
* @return {boolean} True iff the sizes have equal widths and equal
* heights, or if both are null.
*/
static equals(a, b) {
if (a === b) {
return true;
}
if (!a || !b) {
return false;
}
return a.width === b.width && a.height === b.height;
}
};
exports.Size = Size;