chunk-AVLPSIKF.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {
  2. Build
  3. } from "./chunk-IOZKU7B2.js";
  4. // node_modules/@esri/calcite-components/dist/components/observers.js
  5. function createObserver(type, callback, options) {
  6. if (!Build.isBrowser) {
  7. return void 0;
  8. }
  9. const Observer = getObserver(type);
  10. return new Observer(callback, options);
  11. }
  12. function getObserver(type) {
  13. class ExtendedMutationObserver extends window.MutationObserver {
  14. constructor(callback) {
  15. super(callback);
  16. this.observedEntry = [];
  17. this.callback = callback;
  18. }
  19. observe(target, options) {
  20. this.observedEntry.push({ target, options });
  21. return super.observe(target, options);
  22. }
  23. unobserve(target) {
  24. const newObservedEntries = this.observedEntry.filter((observed) => observed.target !== target);
  25. this.observedEntry = [];
  26. this.callback(super.takeRecords(), this);
  27. this.disconnect();
  28. newObservedEntries.forEach((observed) => this.observe(observed.target, observed.options));
  29. }
  30. }
  31. return function() {
  32. return type === "intersection" ? window.IntersectionObserver : type === "mutation" ? ExtendedMutationObserver : window.ResizeObserver;
  33. }();
  34. }
  35. export {
  36. createObserver
  37. };
  38. /*!
  39. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  40. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  41. * v1.0.0-beta.97
  42. */
  43. //# sourceMappingURL=chunk-AVLPSIKF.js.map