UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

52 lines (51 loc) 1.86 kB
/** * DevExtreme (cjs/core/resize_observer.js) * Version: 23.2.6 * Build date: Wed May 01 2024 * * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; exports.default = void 0; var _common = require("./utils/common"); var _window = require("./utils/window"); const window = (0, _window.getWindow)(); const ResizeObserverMock = { observe: _common.noop, unobserve: _common.noop, disconnect: _common.noop }; let ResizeObserverSingleton = function() { function ResizeObserverSingleton() { if (!(0, _window.hasWindow)() || !window.ResizeObserver) { return ResizeObserverMock } this._callbacksMap = new Map; this._observer = new window.ResizeObserver(entries => { entries.forEach(entry => { var _this$_callbacksMap$g; null === (_this$_callbacksMap$g = this._callbacksMap.get(entry.target)) || void 0 === _this$_callbacksMap$g ? void 0 : _this$_callbacksMap$g(entry) }) }) } var _proto = ResizeObserverSingleton.prototype; _proto.observe = function(element, callback) { this._callbacksMap.set(element, callback); this._observer.observe(element) }; _proto.unobserve = function(element) { this._callbacksMap.delete(element); this._observer.unobserve(element) }; _proto.disconnect = function() { this._callbacksMap.clear(); this._observer.disconnect() }; return ResizeObserverSingleton }(); const resizeObserverSingleton = new ResizeObserverSingleton; var _default = resizeObserverSingleton; exports.default = _default; module.exports = exports.default; module.exports.default = exports.default;