1 | import { ResizeObserverBoxOptions } from './ResizeObserverBoxOptions';
|
2 | import { calculateBoxSize } from './algorithms/calculateBoxSize';
|
3 | import { isSVG, isReplacedElement } from './utils/element';
|
4 | var skipNotifyOnElement = function (target) {
|
5 | return !isSVG(target)
|
6 | && !isReplacedElement(target)
|
7 | && getComputedStyle(target).display === 'inline';
|
8 | };
|
9 | var ResizeObservation = (function () {
|
10 | function ResizeObservation(target, observedBox) {
|
11 | this.target = target;
|
12 | this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX;
|
13 | this.lastReportedSize = {
|
14 | inlineSize: 0,
|
15 | blockSize: 0
|
16 | };
|
17 | }
|
18 | ResizeObservation.prototype.isActive = function () {
|
19 | var size = calculateBoxSize(this.target, this.observedBox, true);
|
20 | if (skipNotifyOnElement(this.target)) {
|
21 | this.lastReportedSize = size;
|
22 | }
|
23 | if (this.lastReportedSize.inlineSize !== size.inlineSize
|
24 | || this.lastReportedSize.blockSize !== size.blockSize) {
|
25 | return true;
|
26 | }
|
27 | return false;
|
28 | };
|
29 | return ResizeObservation;
|
30 | }());
|
31 | export { ResizeObservation };
|