70.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. (window["webpackJsonp"] = window["webpackJsonp"] || []).push([[70],{
  2. /***/ "../../node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js":
  3. /*!**********************************************************************************************!*\
  4. !*** D:/web_src/4dkankan_v4/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js ***!
  5. \**********************************************************************************************/
  6. /*! exports provided: default */
  7. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8. "use strict";
  9. __webpack_require__.r(__webpack_exports__);
  10. /* WEBPACK VAR INJECTION */(function(global) {/**
  11. * A collection of shims that provide minimal functionality of the ES6 collections.
  12. *
  13. * These implementations are not meant to be used outside of the ResizeObserver
  14. * modules as they cover only a limited range of use cases.
  15. */
  16. /* eslint-disable require-jsdoc, valid-jsdoc */
  17. var MapShim = (function () {
  18. if (typeof Map !== 'undefined') {
  19. return Map;
  20. }
  21. /**
  22. * Returns index in provided array that matches the specified key.
  23. *
  24. * @param {Array<Array>} arr
  25. * @param {*} key
  26. * @returns {number}
  27. */
  28. function getIndex(arr, key) {
  29. var result = -1;
  30. arr.some(function (entry, index) {
  31. if (entry[0] === key) {
  32. result = index;
  33. return true;
  34. }
  35. return false;
  36. });
  37. return result;
  38. }
  39. return /** @class */ (function () {
  40. function class_1() {
  41. this.__entries__ = [];
  42. }
  43. Object.defineProperty(class_1.prototype, "size", {
  44. /**
  45. * @returns {boolean}
  46. */
  47. get: function () {
  48. return this.__entries__.length;
  49. },
  50. enumerable: true,
  51. configurable: true
  52. });
  53. /**
  54. * @param {*} key
  55. * @returns {*}
  56. */
  57. class_1.prototype.get = function (key) {
  58. var index = getIndex(this.__entries__, key);
  59. var entry = this.__entries__[index];
  60. return entry && entry[1];
  61. };
  62. /**
  63. * @param {*} key
  64. * @param {*} value
  65. * @returns {void}
  66. */
  67. class_1.prototype.set = function (key, value) {
  68. var index = getIndex(this.__entries__, key);
  69. if (~index) {
  70. this.__entries__[index][1] = value;
  71. }
  72. else {
  73. this.__entries__.push([key, value]);
  74. }
  75. };
  76. /**
  77. * @param {*} key
  78. * @returns {void}
  79. */
  80. class_1.prototype.delete = function (key) {
  81. var entries = this.__entries__;
  82. var index = getIndex(entries, key);
  83. if (~index) {
  84. entries.splice(index, 1);
  85. }
  86. };
  87. /**
  88. * @param {*} key
  89. * @returns {void}
  90. */
  91. class_1.prototype.has = function (key) {
  92. return !!~getIndex(this.__entries__, key);
  93. };
  94. /**
  95. * @returns {void}
  96. */
  97. class_1.prototype.clear = function () {
  98. this.__entries__.splice(0);
  99. };
  100. /**
  101. * @param {Function} callback
  102. * @param {*} [ctx=null]
  103. * @returns {void}
  104. */
  105. class_1.prototype.forEach = function (callback, ctx) {
  106. if (ctx === void 0) { ctx = null; }
  107. for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
  108. var entry = _a[_i];
  109. callback.call(ctx, entry[1], entry[0]);
  110. }
  111. };
  112. return class_1;
  113. }());
  114. })();
  115. /**
  116. * Detects whether window and document objects are available in current environment.
  117. */
  118. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
  119. // Returns global object of a current environment.
  120. var global$1 = (function () {
  121. if (typeof global !== 'undefined' && global.Math === Math) {
  122. return global;
  123. }
  124. if (typeof self !== 'undefined' && self.Math === Math) {
  125. return self;
  126. }
  127. if (typeof window !== 'undefined' && window.Math === Math) {
  128. return window;
  129. }
  130. // eslint-disable-next-line no-new-func
  131. return Function('return this')();
  132. })();
  133. /**
  134. * A shim for the requestAnimationFrame which falls back to the setTimeout if
  135. * first one is not supported.
  136. *
  137. * @returns {number} Requests' identifier.
  138. */
  139. var requestAnimationFrame$1 = (function () {
  140. if (typeof requestAnimationFrame === 'function') {
  141. // It's required to use a bounded function because IE sometimes throws
  142. // an "Invalid calling object" error if rAF is invoked without the global
  143. // object on the left hand side.
  144. return requestAnimationFrame.bind(global$1);
  145. }
  146. return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
  147. })();
  148. // Defines minimum timeout before adding a trailing call.
  149. var trailingTimeout = 2;
  150. /**
  151. * Creates a wrapper function which ensures that provided callback will be
  152. * invoked only once during the specified delay period.
  153. *
  154. * @param {Function} callback - Function to be invoked after the delay period.
  155. * @param {number} delay - Delay after which to invoke callback.
  156. * @returns {Function}
  157. */
  158. function throttle (callback, delay) {
  159. var leadingCall = false, trailingCall = false, lastCallTime = 0;
  160. /**
  161. * Invokes the original callback function and schedules new invocation if
  162. * the "proxy" was called during current request.
  163. *
  164. * @returns {void}
  165. */
  166. function resolvePending() {
  167. if (leadingCall) {
  168. leadingCall = false;
  169. callback();
  170. }
  171. if (trailingCall) {
  172. proxy();
  173. }
  174. }
  175. /**
  176. * Callback invoked after the specified delay. It will further postpone
  177. * invocation of the original function delegating it to the
  178. * requestAnimationFrame.
  179. *
  180. * @returns {void}
  181. */
  182. function timeoutCallback() {
  183. requestAnimationFrame$1(resolvePending);
  184. }
  185. /**
  186. * Schedules invocation of the original function.
  187. *
  188. * @returns {void}
  189. */
  190. function proxy() {
  191. var timeStamp = Date.now();
  192. if (leadingCall) {
  193. // Reject immediately following calls.
  194. if (timeStamp - lastCallTime < trailingTimeout) {
  195. return;
  196. }
  197. // Schedule new call to be in invoked when the pending one is resolved.
  198. // This is important for "transitions" which never actually start
  199. // immediately so there is a chance that we might miss one if change
  200. // happens amids the pending invocation.
  201. trailingCall = true;
  202. }
  203. else {
  204. leadingCall = true;
  205. trailingCall = false;
  206. setTimeout(timeoutCallback, delay);
  207. }
  208. lastCallTime = timeStamp;
  209. }
  210. return proxy;
  211. }
  212. // Minimum delay before invoking the update of observers.
  213. var REFRESH_DELAY = 20;
  214. // A list of substrings of CSS properties used to find transition events that
  215. // might affect dimensions of observed elements.
  216. var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
  217. // Check if MutationObserver is available.
  218. var mutationObserverSupported = typeof MutationObserver !== 'undefined';
  219. /**
  220. * Singleton controller class which handles updates of ResizeObserver instances.
  221. */
  222. var ResizeObserverController = /** @class */ (function () {
  223. /**
  224. * Creates a new instance of ResizeObserverController.
  225. *
  226. * @private
  227. */
  228. function ResizeObserverController() {
  229. /**
  230. * Indicates whether DOM listeners have been added.
  231. *
  232. * @private {boolean}
  233. */
  234. this.connected_ = false;
  235. /**
  236. * Tells that controller has subscribed for Mutation Events.
  237. *
  238. * @private {boolean}
  239. */
  240. this.mutationEventsAdded_ = false;
  241. /**
  242. * Keeps reference to the instance of MutationObserver.
  243. *
  244. * @private {MutationObserver}
  245. */
  246. this.mutationsObserver_ = null;
  247. /**
  248. * A list of connected observers.
  249. *
  250. * @private {Array<ResizeObserverSPI>}
  251. */
  252. this.observers_ = [];
  253. this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
  254. this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
  255. }
  256. /**
  257. * Adds observer to observers list.
  258. *
  259. * @param {ResizeObserverSPI} observer - Observer to be added.
  260. * @returns {void}
  261. */
  262. ResizeObserverController.prototype.addObserver = function (observer) {
  263. if (!~this.observers_.indexOf(observer)) {
  264. this.observers_.push(observer);
  265. }
  266. // Add listeners if they haven't been added yet.
  267. if (!this.connected_) {
  268. this.connect_();
  269. }
  270. };
  271. /**
  272. * Removes observer from observers list.
  273. *
  274. * @param {ResizeObserverSPI} observer - Observer to be removed.
  275. * @returns {void}
  276. */
  277. ResizeObserverController.prototype.removeObserver = function (observer) {
  278. var observers = this.observers_;
  279. var index = observers.indexOf(observer);
  280. // Remove observer if it's present in registry.
  281. if (~index) {
  282. observers.splice(index, 1);
  283. }
  284. // Remove listeners if controller has no connected observers.
  285. if (!observers.length && this.connected_) {
  286. this.disconnect_();
  287. }
  288. };
  289. /**
  290. * Invokes the update of observers. It will continue running updates insofar
  291. * it detects changes.
  292. *
  293. * @returns {void}
  294. */
  295. ResizeObserverController.prototype.refresh = function () {
  296. var changesDetected = this.updateObservers_();
  297. // Continue running updates if changes have been detected as there might
  298. // be future ones caused by CSS transitions.
  299. if (changesDetected) {
  300. this.refresh();
  301. }
  302. };
  303. /**
  304. * Updates every observer from observers list and notifies them of queued
  305. * entries.
  306. *
  307. * @private
  308. * @returns {boolean} Returns "true" if any observer has detected changes in
  309. * dimensions of it's elements.
  310. */
  311. ResizeObserverController.prototype.updateObservers_ = function () {
  312. // Collect observers that have active observations.
  313. var activeObservers = this.observers_.filter(function (observer) {
  314. return observer.gatherActive(), observer.hasActive();
  315. });
  316. // Deliver notifications in a separate cycle in order to avoid any
  317. // collisions between observers, e.g. when multiple instances of
  318. // ResizeObserver are tracking the same element and the callback of one
  319. // of them changes content dimensions of the observed target. Sometimes
  320. // this may result in notifications being blocked for the rest of observers.
  321. activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
  322. return activeObservers.length > 0;
  323. };
  324. /**
  325. * Initializes DOM listeners.
  326. *
  327. * @private
  328. * @returns {void}
  329. */
  330. ResizeObserverController.prototype.connect_ = function () {
  331. // Do nothing if running in a non-browser environment or if listeners
  332. // have been already added.
  333. if (!isBrowser || this.connected_) {
  334. return;
  335. }
  336. // Subscription to the "Transitionend" event is used as a workaround for
  337. // delayed transitions. This way it's possible to capture at least the
  338. // final state of an element.
  339. document.addEventListener('transitionend', this.onTransitionEnd_);
  340. window.addEventListener('resize', this.refresh);
  341. if (mutationObserverSupported) {
  342. this.mutationsObserver_ = new MutationObserver(this.refresh);
  343. this.mutationsObserver_.observe(document, {
  344. attributes: true,
  345. childList: true,
  346. characterData: true,
  347. subtree: true
  348. });
  349. }
  350. else {
  351. document.addEventListener('DOMSubtreeModified', this.refresh);
  352. this.mutationEventsAdded_ = true;
  353. }
  354. this.connected_ = true;
  355. };
  356. /**
  357. * Removes DOM listeners.
  358. *
  359. * @private
  360. * @returns {void}
  361. */
  362. ResizeObserverController.prototype.disconnect_ = function () {
  363. // Do nothing if running in a non-browser environment or if listeners
  364. // have been already removed.
  365. if (!isBrowser || !this.connected_) {
  366. return;
  367. }
  368. document.removeEventListener('transitionend', this.onTransitionEnd_);
  369. window.removeEventListener('resize', this.refresh);
  370. if (this.mutationsObserver_) {
  371. this.mutationsObserver_.disconnect();
  372. }
  373. if (this.mutationEventsAdded_) {
  374. document.removeEventListener('DOMSubtreeModified', this.refresh);
  375. }
  376. this.mutationsObserver_ = null;
  377. this.mutationEventsAdded_ = false;
  378. this.connected_ = false;
  379. };
  380. /**
  381. * "Transitionend" event handler.
  382. *
  383. * @private
  384. * @param {TransitionEvent} event
  385. * @returns {void}
  386. */
  387. ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
  388. var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
  389. // Detect whether transition may affect dimensions of an element.
  390. var isReflowProperty = transitionKeys.some(function (key) {
  391. return !!~propertyName.indexOf(key);
  392. });
  393. if (isReflowProperty) {
  394. this.refresh();
  395. }
  396. };
  397. /**
  398. * Returns instance of the ResizeObserverController.
  399. *
  400. * @returns {ResizeObserverController}
  401. */
  402. ResizeObserverController.getInstance = function () {
  403. if (!this.instance_) {
  404. this.instance_ = new ResizeObserverController();
  405. }
  406. return this.instance_;
  407. };
  408. /**
  409. * Holds reference to the controller's instance.
  410. *
  411. * @private {ResizeObserverController}
  412. */
  413. ResizeObserverController.instance_ = null;
  414. return ResizeObserverController;
  415. }());
  416. /**
  417. * Defines non-writable/enumerable properties of the provided target object.
  418. *
  419. * @param {Object} target - Object for which to define properties.
  420. * @param {Object} props - Properties to be defined.
  421. * @returns {Object} Target object.
  422. */
  423. var defineConfigurable = (function (target, props) {
  424. for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
  425. var key = _a[_i];
  426. Object.defineProperty(target, key, {
  427. value: props[key],
  428. enumerable: false,
  429. writable: false,
  430. configurable: true
  431. });
  432. }
  433. return target;
  434. });
  435. /**
  436. * Returns the global object associated with provided element.
  437. *
  438. * @param {Object} target
  439. * @returns {Object}
  440. */
  441. var getWindowOf = (function (target) {
  442. // Assume that the element is an instance of Node, which means that it
  443. // has the "ownerDocument" property from which we can retrieve a
  444. // corresponding global object.
  445. var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
  446. // Return the local global object if it's not possible extract one from
  447. // provided element.
  448. return ownerGlobal || global$1;
  449. });
  450. // Placeholder of an empty content rectangle.
  451. var emptyRect = createRectInit(0, 0, 0, 0);
  452. /**
  453. * Converts provided string to a number.
  454. *
  455. * @param {number|string} value
  456. * @returns {number}
  457. */
  458. function toFloat(value) {
  459. return parseFloat(value) || 0;
  460. }
  461. /**
  462. * Extracts borders size from provided styles.
  463. *
  464. * @param {CSSStyleDeclaration} styles
  465. * @param {...string} positions - Borders positions (top, right, ...)
  466. * @returns {number}
  467. */
  468. function getBordersSize(styles) {
  469. var positions = [];
  470. for (var _i = 1; _i < arguments.length; _i++) {
  471. positions[_i - 1] = arguments[_i];
  472. }
  473. return positions.reduce(function (size, position) {
  474. var value = styles['border-' + position + '-width'];
  475. return size + toFloat(value);
  476. }, 0);
  477. }
  478. /**
  479. * Extracts paddings sizes from provided styles.
  480. *
  481. * @param {CSSStyleDeclaration} styles
  482. * @returns {Object} Paddings box.
  483. */
  484. function getPaddings(styles) {
  485. var positions = ['top', 'right', 'bottom', 'left'];
  486. var paddings = {};
  487. for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
  488. var position = positions_1[_i];
  489. var value = styles['padding-' + position];
  490. paddings[position] = toFloat(value);
  491. }
  492. return paddings;
  493. }
  494. /**
  495. * Calculates content rectangle of provided SVG element.
  496. *
  497. * @param {SVGGraphicsElement} target - Element content rectangle of which needs
  498. * to be calculated.
  499. * @returns {DOMRectInit}
  500. */
  501. function getSVGContentRect(target) {
  502. var bbox = target.getBBox();
  503. return createRectInit(0, 0, bbox.width, bbox.height);
  504. }
  505. /**
  506. * Calculates content rectangle of provided HTMLElement.
  507. *
  508. * @param {HTMLElement} target - Element for which to calculate the content rectangle.
  509. * @returns {DOMRectInit}
  510. */
  511. function getHTMLElementContentRect(target) {
  512. // Client width & height properties can't be
  513. // used exclusively as they provide rounded values.
  514. var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
  515. // By this condition we can catch all non-replaced inline, hidden and
  516. // detached elements. Though elements with width & height properties less
  517. // than 0.5 will be discarded as well.
  518. //
  519. // Without it we would need to implement separate methods for each of
  520. // those cases and it's not possible to perform a precise and performance
  521. // effective test for hidden elements. E.g. even jQuery's ':visible' filter
  522. // gives wrong results for elements with width & height less than 0.5.
  523. if (!clientWidth && !clientHeight) {
  524. return emptyRect;
  525. }
  526. var styles = getWindowOf(target).getComputedStyle(target);
  527. var paddings = getPaddings(styles);
  528. var horizPad = paddings.left + paddings.right;
  529. var vertPad = paddings.top + paddings.bottom;
  530. // Computed styles of width & height are being used because they are the
  531. // only dimensions available to JS that contain non-rounded values. It could
  532. // be possible to utilize the getBoundingClientRect if only it's data wasn't
  533. // affected by CSS transformations let alone paddings, borders and scroll bars.
  534. var width = toFloat(styles.width), height = toFloat(styles.height);
  535. // Width & height include paddings and borders when the 'border-box' box
  536. // model is applied (except for IE).
  537. if (styles.boxSizing === 'border-box') {
  538. // Following conditions are required to handle Internet Explorer which
  539. // doesn't include paddings and borders to computed CSS dimensions.
  540. //
  541. // We can say that if CSS dimensions + paddings are equal to the "client"
  542. // properties then it's either IE, and thus we don't need to subtract
  543. // anything, or an element merely doesn't have paddings/borders styles.
  544. if (Math.round(width + horizPad) !== clientWidth) {
  545. width -= getBordersSize(styles, 'left', 'right') + horizPad;
  546. }
  547. if (Math.round(height + vertPad) !== clientHeight) {
  548. height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
  549. }
  550. }
  551. // Following steps can't be applied to the document's root element as its
  552. // client[Width/Height] properties represent viewport area of the window.
  553. // Besides, it's as well not necessary as the <html> itself neither has
  554. // rendered scroll bars nor it can be clipped.
  555. if (!isDocumentElement(target)) {
  556. // In some browsers (only in Firefox, actually) CSS width & height
  557. // include scroll bars size which can be removed at this step as scroll
  558. // bars are the only difference between rounded dimensions + paddings
  559. // and "client" properties, though that is not always true in Chrome.
  560. var vertScrollbar = Math.round(width + horizPad) - clientWidth;
  561. var horizScrollbar = Math.round(height + vertPad) - clientHeight;
  562. // Chrome has a rather weird rounding of "client" properties.
  563. // E.g. for an element with content width of 314.2px it sometimes gives
  564. // the client width of 315px and for the width of 314.7px it may give
  565. // 314px. And it doesn't happen all the time. So just ignore this delta
  566. // as a non-relevant.
  567. if (Math.abs(vertScrollbar) !== 1) {
  568. width -= vertScrollbar;
  569. }
  570. if (Math.abs(horizScrollbar) !== 1) {
  571. height -= horizScrollbar;
  572. }
  573. }
  574. return createRectInit(paddings.left, paddings.top, width, height);
  575. }
  576. /**
  577. * Checks whether provided element is an instance of the SVGGraphicsElement.
  578. *
  579. * @param {Element} target - Element to be checked.
  580. * @returns {boolean}
  581. */
  582. var isSVGGraphicsElement = (function () {
  583. // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
  584. // interface.
  585. if (typeof SVGGraphicsElement !== 'undefined') {
  586. return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
  587. }
  588. // If it's so, then check that element is at least an instance of the
  589. // SVGElement and that it has the "getBBox" method.
  590. // eslint-disable-next-line no-extra-parens
  591. return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
  592. typeof target.getBBox === 'function'); };
  593. })();
  594. /**
  595. * Checks whether provided element is a document element (<html>).
  596. *
  597. * @param {Element} target - Element to be checked.
  598. * @returns {boolean}
  599. */
  600. function isDocumentElement(target) {
  601. return target === getWindowOf(target).document.documentElement;
  602. }
  603. /**
  604. * Calculates an appropriate content rectangle for provided html or svg element.
  605. *
  606. * @param {Element} target - Element content rectangle of which needs to be calculated.
  607. * @returns {DOMRectInit}
  608. */
  609. function getContentRect(target) {
  610. if (!isBrowser) {
  611. return emptyRect;
  612. }
  613. if (isSVGGraphicsElement(target)) {
  614. return getSVGContentRect(target);
  615. }
  616. return getHTMLElementContentRect(target);
  617. }
  618. /**
  619. * Creates rectangle with an interface of the DOMRectReadOnly.
  620. * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
  621. *
  622. * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
  623. * @returns {DOMRectReadOnly}
  624. */
  625. function createReadOnlyRect(_a) {
  626. var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
  627. // If DOMRectReadOnly is available use it as a prototype for the rectangle.
  628. var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
  629. var rect = Object.create(Constr.prototype);
  630. // Rectangle's properties are not writable and non-enumerable.
  631. defineConfigurable(rect, {
  632. x: x, y: y, width: width, height: height,
  633. top: y,
  634. right: x + width,
  635. bottom: height + y,
  636. left: x
  637. });
  638. return rect;
  639. }
  640. /**
  641. * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
  642. * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
  643. *
  644. * @param {number} x - X coordinate.
  645. * @param {number} y - Y coordinate.
  646. * @param {number} width - Rectangle's width.
  647. * @param {number} height - Rectangle's height.
  648. * @returns {DOMRectInit}
  649. */
  650. function createRectInit(x, y, width, height) {
  651. return { x: x, y: y, width: width, height: height };
  652. }
  653. /**
  654. * Class that is responsible for computations of the content rectangle of
  655. * provided DOM element and for keeping track of it's changes.
  656. */
  657. var ResizeObservation = /** @class */ (function () {
  658. /**
  659. * Creates an instance of ResizeObservation.
  660. *
  661. * @param {Element} target - Element to be observed.
  662. */
  663. function ResizeObservation(target) {
  664. /**
  665. * Broadcasted width of content rectangle.
  666. *
  667. * @type {number}
  668. */
  669. this.broadcastWidth = 0;
  670. /**
  671. * Broadcasted height of content rectangle.
  672. *
  673. * @type {number}
  674. */
  675. this.broadcastHeight = 0;
  676. /**
  677. * Reference to the last observed content rectangle.
  678. *
  679. * @private {DOMRectInit}
  680. */
  681. this.contentRect_ = createRectInit(0, 0, 0, 0);
  682. this.target = target;
  683. }
  684. /**
  685. * Updates content rectangle and tells whether it's width or height properties
  686. * have changed since the last broadcast.
  687. *
  688. * @returns {boolean}
  689. */
  690. ResizeObservation.prototype.isActive = function () {
  691. var rect = getContentRect(this.target);
  692. this.contentRect_ = rect;
  693. return (rect.width !== this.broadcastWidth ||
  694. rect.height !== this.broadcastHeight);
  695. };
  696. /**
  697. * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
  698. * from the corresponding properties of the last observed content rectangle.
  699. *
  700. * @returns {DOMRectInit} Last observed content rectangle.
  701. */
  702. ResizeObservation.prototype.broadcastRect = function () {
  703. var rect = this.contentRect_;
  704. this.broadcastWidth = rect.width;
  705. this.broadcastHeight = rect.height;
  706. return rect;
  707. };
  708. return ResizeObservation;
  709. }());
  710. var ResizeObserverEntry = /** @class */ (function () {
  711. /**
  712. * Creates an instance of ResizeObserverEntry.
  713. *
  714. * @param {Element} target - Element that is being observed.
  715. * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
  716. */
  717. function ResizeObserverEntry(target, rectInit) {
  718. var contentRect = createReadOnlyRect(rectInit);
  719. // According to the specification following properties are not writable
  720. // and are also not enumerable in the native implementation.
  721. //
  722. // Property accessors are not being used as they'd require to define a
  723. // private WeakMap storage which may cause memory leaks in browsers that
  724. // don't support this type of collections.
  725. defineConfigurable(this, { target: target, contentRect: contentRect });
  726. }
  727. return ResizeObserverEntry;
  728. }());
  729. var ResizeObserverSPI = /** @class */ (function () {
  730. /**
  731. * Creates a new instance of ResizeObserver.
  732. *
  733. * @param {ResizeObserverCallback} callback - Callback function that is invoked
  734. * when one of the observed elements changes it's content dimensions.
  735. * @param {ResizeObserverController} controller - Controller instance which
  736. * is responsible for the updates of observer.
  737. * @param {ResizeObserver} callbackCtx - Reference to the public
  738. * ResizeObserver instance which will be passed to callback function.
  739. */
  740. function ResizeObserverSPI(callback, controller, callbackCtx) {
  741. /**
  742. * Collection of resize observations that have detected changes in dimensions
  743. * of elements.
  744. *
  745. * @private {Array<ResizeObservation>}
  746. */
  747. this.activeObservations_ = [];
  748. /**
  749. * Registry of the ResizeObservation instances.
  750. *
  751. * @private {Map<Element, ResizeObservation>}
  752. */
  753. this.observations_ = new MapShim();
  754. if (typeof callback !== 'function') {
  755. throw new TypeError('The callback provided as parameter 1 is not a function.');
  756. }
  757. this.callback_ = callback;
  758. this.controller_ = controller;
  759. this.callbackCtx_ = callbackCtx;
  760. }
  761. /**
  762. * Starts observing provided element.
  763. *
  764. * @param {Element} target - Element to be observed.
  765. * @returns {void}
  766. */
  767. ResizeObserverSPI.prototype.observe = function (target) {
  768. if (!arguments.length) {
  769. throw new TypeError('1 argument required, but only 0 present.');
  770. }
  771. // Do nothing if current environment doesn't have the Element interface.
  772. if (typeof Element === 'undefined' || !(Element instanceof Object)) {
  773. return;
  774. }
  775. if (!(target instanceof getWindowOf(target).Element)) {
  776. throw new TypeError('parameter 1 is not of type "Element".');
  777. }
  778. var observations = this.observations_;
  779. // Do nothing if element is already being observed.
  780. if (observations.has(target)) {
  781. return;
  782. }
  783. observations.set(target, new ResizeObservation(target));
  784. this.controller_.addObserver(this);
  785. // Force the update of observations.
  786. this.controller_.refresh();
  787. };
  788. /**
  789. * Stops observing provided element.
  790. *
  791. * @param {Element} target - Element to stop observing.
  792. * @returns {void}
  793. */
  794. ResizeObserverSPI.prototype.unobserve = function (target) {
  795. if (!arguments.length) {
  796. throw new TypeError('1 argument required, but only 0 present.');
  797. }
  798. // Do nothing if current environment doesn't have the Element interface.
  799. if (typeof Element === 'undefined' || !(Element instanceof Object)) {
  800. return;
  801. }
  802. if (!(target instanceof getWindowOf(target).Element)) {
  803. throw new TypeError('parameter 1 is not of type "Element".');
  804. }
  805. var observations = this.observations_;
  806. // Do nothing if element is not being observed.
  807. if (!observations.has(target)) {
  808. return;
  809. }
  810. observations.delete(target);
  811. if (!observations.size) {
  812. this.controller_.removeObserver(this);
  813. }
  814. };
  815. /**
  816. * Stops observing all elements.
  817. *
  818. * @returns {void}
  819. */
  820. ResizeObserverSPI.prototype.disconnect = function () {
  821. this.clearActive();
  822. this.observations_.clear();
  823. this.controller_.removeObserver(this);
  824. };
  825. /**
  826. * Collects observation instances the associated element of which has changed
  827. * it's content rectangle.
  828. *
  829. * @returns {void}
  830. */
  831. ResizeObserverSPI.prototype.gatherActive = function () {
  832. var _this = this;
  833. this.clearActive();
  834. this.observations_.forEach(function (observation) {
  835. if (observation.isActive()) {
  836. _this.activeObservations_.push(observation);
  837. }
  838. });
  839. };
  840. /**
  841. * Invokes initial callback function with a list of ResizeObserverEntry
  842. * instances collected from active resize observations.
  843. *
  844. * @returns {void}
  845. */
  846. ResizeObserverSPI.prototype.broadcastActive = function () {
  847. // Do nothing if observer doesn't have active observations.
  848. if (!this.hasActive()) {
  849. return;
  850. }
  851. var ctx = this.callbackCtx_;
  852. // Create ResizeObserverEntry instance for every active observation.
  853. var entries = this.activeObservations_.map(function (observation) {
  854. return new ResizeObserverEntry(observation.target, observation.broadcastRect());
  855. });
  856. this.callback_.call(ctx, entries, ctx);
  857. this.clearActive();
  858. };
  859. /**
  860. * Clears the collection of active observations.
  861. *
  862. * @returns {void}
  863. */
  864. ResizeObserverSPI.prototype.clearActive = function () {
  865. this.activeObservations_.splice(0);
  866. };
  867. /**
  868. * Tells whether observer has active observations.
  869. *
  870. * @returns {boolean}
  871. */
  872. ResizeObserverSPI.prototype.hasActive = function () {
  873. return this.activeObservations_.length > 0;
  874. };
  875. return ResizeObserverSPI;
  876. }());
  877. // Registry of internal observers. If WeakMap is not available use current shim
  878. // for the Map collection as it has all required methods and because WeakMap
  879. // can't be fully polyfilled anyway.
  880. var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
  881. /**
  882. * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
  883. * exposing only those methods and properties that are defined in the spec.
  884. */
  885. var ResizeObserver = /** @class */ (function () {
  886. /**
  887. * Creates a new instance of ResizeObserver.
  888. *
  889. * @param {ResizeObserverCallback} callback - Callback that is invoked when
  890. * dimensions of the observed elements change.
  891. */
  892. function ResizeObserver(callback) {
  893. if (!(this instanceof ResizeObserver)) {
  894. throw new TypeError('Cannot call a class as a function.');
  895. }
  896. if (!arguments.length) {
  897. throw new TypeError('1 argument required, but only 0 present.');
  898. }
  899. var controller = ResizeObserverController.getInstance();
  900. var observer = new ResizeObserverSPI(callback, controller, this);
  901. observers.set(this, observer);
  902. }
  903. return ResizeObserver;
  904. }());
  905. // Expose public methods of ResizeObserver.
  906. [
  907. 'observe',
  908. 'unobserve',
  909. 'disconnect'
  910. ].forEach(function (method) {
  911. ResizeObserver.prototype[method] = function () {
  912. var _a;
  913. return (_a = observers.get(this))[method].apply(_a, arguments);
  914. };
  915. });
  916. var index = (function () {
  917. // Export existing implementation if available.
  918. if (typeof global$1.ResizeObserver !== 'undefined') {
  919. return global$1.ResizeObserver;
  920. }
  921. return ResizeObserver;
  922. })();
  923. /* harmony default export */ __webpack_exports__["default"] = (index);
  924. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  925. /***/ })
  926. }]);
  927. //# sourceMappingURL=70.js.map