1 | import { resizeObservers } from '../utils/resizeObservers';
|
2 | import { ResizeObserverEntry } from '../ResizeObserverEntry';
|
3 | import { calculateDepthForNode } from './calculateDepthForNode';
|
4 | import { calculateBoxSize } from './calculateBoxSize';
|
5 | var broadcastActiveObservations = function () {
|
6 | var shallowestDepth = Infinity;
|
7 | var callbacks = [];
|
8 | resizeObservers.forEach(function processObserver(ro) {
|
9 | if (ro.activeTargets.length === 0) {
|
10 | return;
|
11 | }
|
12 | var entries = [];
|
13 | ro.activeTargets.forEach(function processTarget(ot) {
|
14 | var entry = new ResizeObserverEntry(ot.target);
|
15 | var targetDepth = calculateDepthForNode(ot.target);
|
16 | entries.push(entry);
|
17 | ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox);
|
18 | if (targetDepth < shallowestDepth) {
|
19 | shallowestDepth = targetDepth;
|
20 | }
|
21 | });
|
22 | callbacks.push(function resizeObserverCallback() {
|
23 | ro.callback.call(ro.observer, entries, ro.observer);
|
24 | });
|
25 | ro.activeTargets.splice(0, ro.activeTargets.length);
|
26 | });
|
27 | for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
|
28 | var callback = callbacks_1[_i];
|
29 | callback();
|
30 | }
|
31 | return shallowestDepth;
|
32 | };
|
33 | export { broadcastActiveObservations };
|