UNPKG

@uifabric/utilities

Version:

Fluent UI React utilities for building components.

52 lines 1.83 kB
/** * Rectangle helper class. * * @public * {@docCategory Rectangle} */ var Rectangle = /** @class */ (function () { function Rectangle(left, right, top, bottom) { if (left === void 0) { left = 0; } if (right === void 0) { right = 0; } if (top === void 0) { top = 0; } if (bottom === void 0) { bottom = 0; } this.top = top; this.bottom = bottom; this.left = left; this.right = right; } Object.defineProperty(Rectangle.prototype, "width", { /** * Calculated automatically by subtracting the right from left */ get: function () { return this.right - this.left; }, enumerable: true, configurable: true }); Object.defineProperty(Rectangle.prototype, "height", { /** * Calculated automatically by subtracting the bottom from top. */ get: function () { return this.bottom - this.top; }, enumerable: true, configurable: true }); /** * Tests if another rect is approximately equal to this rect (within 4 decimal places.) */ Rectangle.prototype.equals = function (rect) { // Fixing to 4 decimal places because it allows enough precision and will handle cases when something // should be rounded, like .999999 should round to 1. return (parseFloat(this.top.toFixed(4)) === parseFloat(rect.top.toFixed(4)) && parseFloat(this.bottom.toFixed(4)) === parseFloat(rect.bottom.toFixed(4)) && parseFloat(this.left.toFixed(4)) === parseFloat(rect.left.toFixed(4)) && parseFloat(this.right.toFixed(4)) === parseFloat(rect.right.toFixed(4))); }; return Rectangle; }()); export { Rectangle }; //# sourceMappingURL=Rectangle.js.map