2015-01-29 17:10:49 -08:00
|
|
|
/**
|
2016-07-05 06:34:00 -07:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-16 18:24:55 -08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-07-05 06:34:00 -07:00
|
|
|
*
|
2018-05-10 19:06:46 -07:00
|
|
|
* @format
|
2015-01-29 17:10:49 -08:00
|
|
|
*/
|
|
|
|
|
2015-11-30 17:14:10 -08:00
|
|
|
'use strict';
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2018-03-03 15:04:46 -08:00
|
|
|
const PooledClass = require('PooledClass');
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2018-03-03 15:04:46 -08:00
|
|
|
const twoArgumentPooler = PooledClass.twoArgumentPooler;
|
2015-01-29 17:10:49 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PooledClass representing the bounding rectangle of a region.
|
|
|
|
*
|
|
|
|
* @param {number} width Width of bounding rectangle.
|
|
|
|
* @param {number} height Height of bounding rectangle.
|
|
|
|
* @constructor BoundingDimensions
|
|
|
|
*/
|
|
|
|
function BoundingDimensions(width, height) {
|
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
|
|
|
}
|
|
|
|
|
2015-11-06 19:50:10 -08:00
|
|
|
BoundingDimensions.prototype.destructor = function() {
|
|
|
|
this.width = null;
|
|
|
|
this.height = null;
|
|
|
|
};
|
|
|
|
|
2015-01-29 17:10:49 -08:00
|
|
|
/**
|
|
|
|
* @param {HTMLElement} element Element to return `BoundingDimensions` for.
|
|
|
|
* @return {BoundingDimensions} Bounding dimensions of `element`.
|
|
|
|
*/
|
|
|
|
BoundingDimensions.getPooledFromElement = function(element) {
|
|
|
|
return BoundingDimensions.getPooled(
|
|
|
|
element.offsetWidth,
|
2018-05-10 19:06:46 -07:00
|
|
|
element.offsetHeight,
|
2015-01-29 17:10:49 -08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
PooledClass.addPoolingTo(BoundingDimensions, twoArgumentPooler);
|
|
|
|
|
|
|
|
module.exports = BoundingDimensions;
|