uikit 3.11.2-dev.03e47c2ff → 3.11.2-dev.06fe7f1d0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/css/uikit-core-rtl.css +12 -6
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +12 -6
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +12 -6
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +12 -6
  9. package/dist/css/uikit.min.css +1 -1
  10. package/dist/js/components/countdown.js +3 -3
  11. package/dist/js/components/countdown.min.js +1 -1
  12. package/dist/js/components/filter.js +1 -1
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +4 -14
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +4 -14
  17. package/dist/js/components/lightbox.min.js +1 -1
  18. package/dist/js/components/notification.js +1 -1
  19. package/dist/js/components/notification.min.js +1 -1
  20. package/dist/js/components/parallax.js +8 -9
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +8 -9
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +59 -78
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +8 -9
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +23 -45
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +1 -1
  31. package/dist/js/components/sortable.min.js +1 -1
  32. package/dist/js/components/tooltip.js +1 -1
  33. package/dist/js/components/tooltip.min.js +1 -1
  34. package/dist/js/components/upload.js +2 -1
  35. package/dist/js/components/upload.min.js +1 -1
  36. package/dist/js/uikit-core.js +357 -264
  37. package/dist/js/uikit-core.min.js +1 -1
  38. package/dist/js/uikit-icons.js +1 -1
  39. package/dist/js/uikit-icons.min.js +1 -1
  40. package/dist/js/uikit.js +414 -361
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/hooks.js +2 -2
  44. package/src/js/api/state.js +173 -140
  45. package/src/js/components/countdown.js +2 -2
  46. package/src/js/components/internal/slider-preload.js +4 -32
  47. package/src/js/components/slider.js +39 -42
  48. package/src/js/components/upload.js +2 -1
  49. package/src/js/core/accordion.js +6 -1
  50. package/src/js/core/core.js +2 -75
  51. package/src/js/core/cover.js +5 -1
  52. package/src/js/core/drop.js +3 -1
  53. package/src/js/core/form-custom.js +2 -2
  54. package/src/js/core/height-viewport.js +3 -0
  55. package/src/js/core/img.js +16 -24
  56. package/src/js/core/offcanvas.js +2 -1
  57. package/src/js/core/sticky.js +27 -33
  58. package/src/js/core/switcher.js +11 -3
  59. package/src/js/core/toggle.js +3 -1
  60. package/src/js/core/video.js +13 -1
  61. package/src/js/mixin/lazyload.js +20 -0
  62. package/src/js/mixin/parallax.js +8 -9
  63. package/src/js/mixin/slider.js +0 -6
  64. package/src/js/mixin/slideshow.js +0 -4
  65. package/src/js/mixin/swipe.js +72 -0
  66. package/src/js/util/index.js +1 -0
  67. package/src/js/util/observer.js +36 -0
  68. package/src/less/components/utility.less +6 -3
  69. package/src/scss/components/utility.scss +6 -3
  70. package/tests/parallax.html +2 -2
  71. package/tests/sticky-parallax.html +1 -1
  72. package/tests/utility.html +17 -0
@@ -1,18 +1,4 @@
1
- import {
2
- css,
3
- fastdom,
4
- getEventPos,
5
- inBrowser,
6
- isTouch,
7
- on,
8
- once,
9
- parent,
10
- pointerCancel,
11
- pointerDown,
12
- pointerUp,
13
- toMs,
14
- trigger,
15
- } from 'uikit-util';
1
+ import { css, fastdom, inBrowser, observeResize, on, toMs } from 'uikit-util';
16
2
 
17
3
  export default function (UIkit) {
18
4
  if (!inBrowser) {
@@ -32,27 +18,7 @@ export default function (UIkit) {
32
18
 
33
19
  on(window, 'load resize', handleResize);
34
20
  on(document, 'loadedmetadata load', handleResize, true);
35
-
36
- if ('ResizeObserver' in window) {
37
- new ResizeObserver(handleResize).observe(document.documentElement);
38
- }
39
-
40
- // throttle `scroll` event (Safari triggers multiple `scroll` events per frame)
41
- let pending;
42
- on(
43
- window,
44
- 'scroll',
45
- (e) => {
46
- if (pending) {
47
- return;
48
- }
49
- pending = true;
50
- fastdom.read(() => (pending = false));
51
-
52
- UIkit.update(null, e.type);
53
- },
54
- { passive: true, capture: true }
55
- );
21
+ observeResize(document.documentElement, handleResize);
56
22
 
57
23
  let started = 0;
58
24
  on(
@@ -71,43 +37,4 @@ export default function (UIkit) {
71
37
  },
72
38
  true
73
39
  );
74
-
75
- on(
76
- document,
77
- pointerDown,
78
- (e) => {
79
- if (!isTouch(e)) {
80
- return;
81
- }
82
-
83
- // Handle Swipe Gesture
84
- const pos = getEventPos(e);
85
- const target = 'tagName' in e.target ? e.target : parent(e.target);
86
- once(document, `${pointerUp} ${pointerCancel} scroll`, (e) => {
87
- const { x, y } = getEventPos(e);
88
-
89
- // swipe
90
- if (
91
- (e.type !== 'scroll' && target && x && Math.abs(pos.x - x) > 100) ||
92
- (y && Math.abs(pos.y - y) > 100)
93
- ) {
94
- setTimeout(() => {
95
- trigger(target, 'swipe');
96
- trigger(target, `swipe${swipeDirection(pos.x, pos.y, x, y)}`);
97
- });
98
- }
99
- });
100
- },
101
- { passive: true }
102
- );
103
- }
104
-
105
- function swipeDirection(x1, y1, x2, y2) {
106
- return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
107
- ? x1 - x2 > 0
108
- ? 'Left'
109
- : 'Right'
110
- : y1 - y2 > 0
111
- ? 'Up'
112
- : 'Down';
113
40
  }
@@ -1,5 +1,5 @@
1
1
  import Video from './video';
2
- import { css, Dimensions, parent } from 'uikit-util';
2
+ import { css, Dimensions, observeResize, parent } from 'uikit-util';
3
3
 
4
4
  export default {
5
5
  mixins: [Video],
@@ -13,6 +13,10 @@ export default {
13
13
  automute: true,
14
14
  },
15
15
 
16
+ connected() {
17
+ this.registerObserver(observeResize(this.$el, () => this.$emit('resize')));
18
+ },
19
+
16
20
  update: {
17
21
  read() {
18
22
  const el = this.$el;
@@ -1,4 +1,5 @@
1
1
  import Container from '../mixin/container';
2
+ import Lazyload from '../mixin/lazyload';
2
3
  import Position from '../mixin/position';
3
4
  import Togglable from '../mixin/togglable';
4
5
  import {
@@ -30,7 +31,7 @@ import {
30
31
  export let active;
31
32
 
32
33
  export default {
33
- mixins: [Container, Position, Togglable],
34
+ mixins: [Container, Lazyload, Position, Togglable],
34
35
 
35
36
  args: 'pos',
36
37
 
@@ -84,6 +85,7 @@ export default {
84
85
  mode: this.mode,
85
86
  }).$el;
86
87
  attr(this.target, 'aria-haspopup', true);
88
+ this.lazyload(this.target);
87
89
  }
88
90
  },
89
91
 
@@ -60,7 +60,7 @@ export default {
60
60
  name: 'change',
61
61
 
62
62
  handler() {
63
- this.$update();
63
+ this.$emit();
64
64
  },
65
65
  },
66
66
 
@@ -72,7 +72,7 @@ export default {
72
72
  },
73
73
 
74
74
  handler() {
75
- this.$update();
75
+ this.$emit();
76
76
  },
77
77
  },
78
78
  ],
@@ -1,3 +1,4 @@
1
+ import Class from '../mixin/class';
1
2
  import {
2
3
  boxModelAdjust,
3
4
  css,
@@ -14,6 +15,8 @@ import {
14
15
  } from 'uikit-util';
15
16
 
16
17
  export default {
18
+ mixins: [Class],
19
+
17
20
  props: {
18
21
  expand: Boolean,
19
22
  offsetTop: Boolean,
@@ -8,10 +8,12 @@ import {
8
8
  escape,
9
9
  fragment,
10
10
  hasAttr,
11
+ hasIntersectionObserver,
11
12
  includes,
12
13
  isArray,
13
14
  isEmpty,
14
15
  isTag,
16
+ observeIntersection,
15
17
  parent,
16
18
  parseOptions,
17
19
  queryAll,
@@ -23,7 +25,6 @@ import {
23
25
  } from 'uikit-util';
24
26
 
25
27
  const nativeLazyLoad = 'loading' in HTMLImageElement.prototype;
26
- const nativeIsIntersecting = 'isIntersecting' in IntersectionObserverEntry.prototype; // Old chromium based browsers (UC Browser) did not implement `isIntersecting`
27
28
 
28
29
  export default {
29
30
  args: 'dataSrc',
@@ -53,13 +54,13 @@ export default {
53
54
  },
54
55
 
55
56
  watch() {
56
- this.observe();
57
+ this.$reset();
57
58
  },
58
59
  },
59
60
  },
60
61
 
61
62
  connected() {
62
- if (this.loading !== 'lazy' || !window.IntersectionObserver || !nativeIsIntersecting) {
63
+ if (this.loading !== 'lazy' || !hasIntersectionObserver) {
63
64
  this.load();
64
65
  return;
65
66
  }
@@ -75,28 +76,27 @@ export default {
75
76
 
76
77
  ensureSrcAttribute(this.$el);
77
78
 
78
- const rootMargin = `${toPx(this.offsetTop, 'height')}px ${toPx(
79
- this.offsetLeft,
80
- 'width'
81
- )}px`;
82
- this.observer = new IntersectionObserver(
83
- (entries) => {
84
- if (entries.some((entry) => entry.isIntersecting)) {
79
+ this.registerObserver(
80
+ observeIntersection(
81
+ this.target,
82
+ (entries, observer) => {
85
83
  this.load();
86
- this.observer.disconnect();
84
+ observer.disconnect();
85
+ },
86
+ {
87
+ rootMargin: `${toPx(this.offsetTop, 'height')}px ${toPx(
88
+ this.offsetLeft,
89
+ 'width'
90
+ )}px`,
87
91
  }
88
- },
89
- { rootMargin }
92
+ )
90
93
  );
91
- this.observe();
92
94
  },
93
95
 
94
96
  disconnected() {
95
97
  if (this._data.image) {
96
98
  this._data.image.onload = '';
97
99
  }
98
-
99
- this.observer?.disconnect();
100
100
  },
101
101
 
102
102
  update: {
@@ -132,14 +132,6 @@ export default {
132
132
  setSrcAttrs(this.$el, image.currentSrc);
133
133
  return (this._data.image = image);
134
134
  },
135
-
136
- observe() {
137
- if (this._connected && !this._data.image) {
138
- for (const el of this.target) {
139
- this.observer.observe(el);
140
- }
141
- }
142
- },
143
135
  },
144
136
  };
145
137
 
@@ -1,4 +1,5 @@
1
1
  import Modal from '../mixin/modal';
2
+ import Swipe from '../mixin/swipe';
2
3
  import {
3
4
  $,
4
5
  addClass,
@@ -15,7 +16,7 @@ import {
15
16
  } from 'uikit-util';
16
17
 
17
18
  export default {
18
- mixins: [Modal],
19
+ mixins: [Modal, Swipe],
19
20
 
20
21
  args: 'mode',
21
22
 
@@ -13,7 +13,6 @@ import {
13
13
  offset as getOffset,
14
14
  getScrollingElement,
15
15
  hasClass,
16
- isNumeric,
17
16
  isString,
18
17
  isVisible,
19
18
  noop,
@@ -29,6 +28,7 @@ import {
29
28
  toPx,
30
29
  trigger,
31
30
  within,
31
+ intersectRect,
32
32
  } from 'uikit-util';
33
33
 
34
34
  export default {
@@ -119,34 +119,29 @@ export default {
119
119
  return window;
120
120
  },
121
121
 
122
+ filter() {
123
+ return this.targetOffset !== false;
124
+ },
125
+
122
126
  handler() {
123
- if (!(this.targetOffset !== false && location.hash && scrollTop(window) > 0)) {
127
+ if (!location.hash || scrollTop(window) === 0) {
124
128
  return;
125
129
  }
126
130
 
127
- const target = $(location.hash);
128
-
129
- if (target) {
130
- fastdom.read(() => {
131
- const { top } = getOffset(target);
132
- const elTop = getOffset(this.$el).top;
133
- const elHeight = this.$el.offsetHeight;
134
-
135
- if (
136
- this.isFixed &&
137
- elTop + elHeight >= top &&
138
- elTop <= top + target.offsetHeight
139
- ) {
140
- scrollTop(
141
- window,
142
- top -
143
- elHeight -
144
- (isNumeric(this.targetOffset) ? this.targetOffset : 0) -
145
- this._data.offset
146
- );
147
- }
148
- });
149
- }
131
+ fastdom.read(() => {
132
+ const targetOffset = getOffset($(location.hash));
133
+ const elOffset = getOffset(this.$el);
134
+
135
+ if (this.isFixed && intersectRect(targetOffset, elOffset)) {
136
+ scrollTop(
137
+ window,
138
+ targetOffset.top -
139
+ elOffset.height -
140
+ toPx(this.targetOffset, 'height') -
141
+ toPx(this.offset, 'height')
142
+ );
143
+ }
144
+ });
150
145
  },
151
146
  },
152
147
  ],
@@ -177,20 +172,19 @@ export default {
177
172
  }
178
173
 
179
174
  const referenceElement = this.isFixed ? this.placeholder : this.$el;
175
+ const windowHeight = getHeight(window);
180
176
 
181
177
  let position = this.position;
182
-
183
- if (position === 'auto') {
184
- position = height > getHeight(window) ? 'bottom' : 'top';
178
+ if (position === 'auto' && height > windowHeight) {
179
+ position = 'bottom';
185
180
  }
186
181
 
187
- let offset = this.offset;
182
+ let offset = toPx(this.offset, 'height', referenceElement);
188
183
  if (position === 'bottom') {
189
- offset += '+100vh-100%';
184
+ offset += windowHeight - height;
190
185
  }
191
- offset = toPx(offset, 'height', referenceElement);
192
186
 
193
- const overflow = Math.max(0, height + offset - getHeight(window));
187
+ const overflow = Math.max(0, height + offset - windowHeight);
194
188
  const topOffset = getOffset(referenceElement).top;
195
189
  const offsetParentTop = getOffset(referenceElement.offsetParent).top;
196
190
 
@@ -200,7 +194,7 @@ export default {
200
194
  const start = Math.max(top, topOffset) - offset;
201
195
  const end = bottom
202
196
  ? bottom - getOffset(this.$el).height + overflow - offset
203
- : getScrollingElement(this.$el).scrollHeight - getHeight(window);
197
+ : getScrollingElement(this.$el).scrollHeight - windowHeight;
204
198
 
205
199
  return {
206
200
  start,
@@ -1,3 +1,5 @@
1
+ import Lazyload from '../mixin/lazyload';
2
+ import Swipe from '../mixin/swipe';
1
3
  import Togglable from '../mixin/togglable';
2
4
  import {
3
5
  $$,
@@ -17,7 +19,7 @@ import {
17
19
  } from 'uikit-util';
18
20
 
19
21
  export default {
20
- mixins: [Togglable],
22
+ mixins: [Lazyload, Swipe, Togglable],
21
23
 
22
24
  args: 'connect',
23
25
 
@@ -26,7 +28,6 @@ export default {
26
28
  toggle: String,
27
29
  itemNav: String,
28
30
  active: Number,
29
- swiping: Boolean,
30
31
  },
31
32
 
32
33
  data: {
@@ -34,7 +35,6 @@ export default {
34
35
  toggle: '> * > :first-child',
35
36
  itemNav: false,
36
37
  active: 0,
37
- swiping: true,
38
38
  cls: 'uk-active',
39
39
  attrItem: 'uk-switcher-item',
40
40
  },
@@ -79,6 +79,14 @@ export default {
79
79
  this.toggles.some((toggle) => within(toggle, child))
80
80
  );
81
81
  },
82
+
83
+ swipeTarget() {
84
+ return this.connects;
85
+ },
86
+ },
87
+
88
+ connected() {
89
+ this.lazyload(this.$el, this.connects);
82
90
  },
83
91
 
84
92
  events: [
@@ -1,3 +1,4 @@
1
+ import Lazyload from '../mixin/lazyload';
1
2
  import Media from '../mixin/media';
2
3
  import Togglable from '../mixin/togglable';
3
4
  import {
@@ -22,7 +23,7 @@ import {
22
23
  const KEY_SPACE = 32;
23
24
 
24
25
  export default {
25
- mixins: [Media, Togglable],
26
+ mixins: [Lazyload, Media, Togglable],
26
27
 
27
28
  args: 'target',
28
29
 
@@ -44,6 +45,7 @@ export default {
44
45
  if (!includes(this.mode, 'media') && !isFocusable(this.$el)) {
45
46
  attr(this.$el, 'tabindex', '0');
46
47
  }
48
+ this.lazyload(this.$el, this.target);
47
49
  },
48
50
 
49
51
  computed: {
@@ -1,4 +1,14 @@
1
- import { css, hasAttr, isInView, isVideo, isVisible, mute, pause, play } from 'uikit-util';
1
+ import {
2
+ css,
3
+ hasAttr,
4
+ isInView,
5
+ isVideo,
6
+ isVisible,
7
+ mute,
8
+ observeIntersection,
9
+ pause,
10
+ play,
11
+ } from 'uikit-util';
2
12
 
3
13
  export default {
4
14
  args: 'autoplay',
@@ -27,6 +37,8 @@ export default {
27
37
  if (this.automute) {
28
38
  mute(this.$el);
29
39
  }
40
+
41
+ this.registerObserver(observeIntersection(this.$el, () => this.$emit('resize')));
30
42
  },
31
43
 
32
44
  update: {
@@ -0,0 +1,20 @@
1
+ import { $$, isFunction, observeIntersection, removeAttr, toNodes } from 'uikit-util';
2
+
3
+ export default {
4
+ methods: {
5
+ lazyload(observeTargets = this.$el, targets = this.$el) {
6
+ this.registerObserver(
7
+ observeIntersection(observeTargets, (entries, observer) => {
8
+ for (const el of toNodes(isFunction(targets) ? targets() : targets)) {
9
+ $$('[loading="lazy"]', el).forEach((el) => removeAttr(el, 'loading'));
10
+ }
11
+ for (const el of entries
12
+ .filter(({ isIntersecting }) => isIntersecting)
13
+ .map(({ target }) => target)) {
14
+ observer.unobserve(el);
15
+ }
16
+ })
17
+ );
18
+ },
19
+ },
20
+ };
@@ -57,7 +57,7 @@ export default {
57
57
  },
58
58
 
59
59
  events: {
60
- bgimageload() {
60
+ load() {
61
61
  this.$emit();
62
62
  },
63
63
  },
@@ -68,13 +68,11 @@ export default {
68
68
  },
69
69
 
70
70
  getCss(percent) {
71
- return keys(this.props).reduce(
72
- (css, prop) => {
73
- this.props[prop](css, percent);
74
- return css;
75
- },
76
- { transform: '', filter: '' }
77
- );
71
+ const css = { transform: '', filter: '' };
72
+ for (const prop in this.props) {
73
+ this.props[prop](css, percent);
74
+ }
75
+ return css;
78
76
  },
79
77
  },
80
78
  };
@@ -257,8 +255,9 @@ function getBackgroundImageDimensions(el) {
257
255
  if (!image.naturalWidth) {
258
256
  image.onload = () => {
259
257
  dimensions[src] = toDimensions(image);
260
- trigger(el, 'bgimageload');
258
+ trigger(el, 'load');
261
259
  };
260
+ return toDimensions(image);
262
261
  }
263
262
  }
264
263
 
@@ -82,12 +82,6 @@ export default {
82
82
  },
83
83
  },
84
84
 
85
- events: {
86
- itemshown() {
87
- this.$update(this.list);
88
- },
89
- },
90
-
91
85
  methods: {
92
86
  show(index, force = false) {
93
87
  if (this.dragging || !this.length) {
@@ -28,10 +28,6 @@ export default {
28
28
  },
29
29
 
30
30
  events: {
31
- 'itemshow itemhide itemshown itemhidden'({ target }) {
32
- this.$update(target);
33
- },
34
-
35
31
  beforeitemshow({ target }) {
36
32
  addClass(target, this.clsActive);
37
33
  },
@@ -0,0 +1,72 @@
1
+ import {
2
+ getEventPos,
3
+ isTouch,
4
+ once,
5
+ parent,
6
+ pointerCancel,
7
+ pointerDown,
8
+ pointerUp,
9
+ trigger,
10
+ } from 'uikit-util';
11
+ import { registerEvent } from '../api/state';
12
+
13
+ export default {
14
+ props: {
15
+ swiping: Boolean,
16
+ },
17
+
18
+ data: {
19
+ swiping: true,
20
+ },
21
+
22
+ computed: {
23
+ swipeTarget(props, $el) {
24
+ return $el;
25
+ },
26
+ },
27
+
28
+ connected() {
29
+ if (!this.swiping) {
30
+ return;
31
+ }
32
+
33
+ registerEvent(this, {
34
+ el: this.swipeTarget,
35
+ name: pointerDown,
36
+ passive: true,
37
+ handler(e) {
38
+ if (!isTouch(e)) {
39
+ return;
40
+ }
41
+
42
+ // Handle Swipe Gesture
43
+ const pos = getEventPos(e);
44
+ const target = 'tagName' in e.target ? e.target : parent(e.target);
45
+ once(document, `${pointerUp} ${pointerCancel} scroll`, (e) => {
46
+ const { x, y } = getEventPos(e);
47
+
48
+ // swipe
49
+ if (
50
+ (e.type !== 'scroll' && target && x && Math.abs(pos.x - x) > 100) ||
51
+ (y && Math.abs(pos.y - y) > 100)
52
+ ) {
53
+ setTimeout(() => {
54
+ trigger(target, 'swipe');
55
+ trigger(target, `swipe${swipeDirection(pos.x, pos.y, x, y)}`);
56
+ });
57
+ }
58
+ });
59
+ },
60
+ });
61
+ },
62
+ };
63
+
64
+ function swipeDirection(x1, y1, x2, y2) {
65
+ return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
66
+ ? x1 - x2 > 0
67
+ ? 'Left'
68
+ : 'Right'
69
+ : y1 - y2 > 0
70
+ ? 'Up'
71
+ : 'Down';
72
+ }
@@ -10,6 +10,7 @@ export * from './fastdom';
10
10
  export * from './filter';
11
11
  export * from './lang';
12
12
  export * from './mouse';
13
+ export * from './observer';
13
14
  export * from './options';
14
15
  export * from './player';
15
16
  export * from './position';
@@ -0,0 +1,36 @@
1
+ import { toNodes } from './lang';
2
+
3
+ // Old chromium based browsers (UC Browser) did not implement `isIntersecting`
4
+ export const hasIntersectionObserver =
5
+ window.IntersectionObserver && 'isIntersecting' in IntersectionObserverEntry.prototype;
6
+ export function observeIntersection(targets, cb, options, intersecting = true) {
7
+ if (!hasIntersectionObserver) {
8
+ return;
9
+ }
10
+
11
+ const observer = new IntersectionObserver((entries, observer) => {
12
+ if (!intersecting || entries.some((entry) => entry.isIntersecting)) {
13
+ cb(entries, observer);
14
+ }
15
+ }, options);
16
+ for (const el of toNodes(targets)) {
17
+ observer.observe(el);
18
+ }
19
+ return observer;
20
+ }
21
+
22
+ const hasResizeObserver = window.ResizeObserver;
23
+ export function observeResize(targets, cb, options = { box: 'border-box' }) {
24
+ if (!hasResizeObserver) {
25
+ return;
26
+ }
27
+
28
+ const observer = new ResizeObserver((entries, observer) => {
29
+ cb(entries, observer);
30
+ });
31
+ for (const el of toNodes(targets)) {
32
+ observer.observe(el, options);
33
+ }
34
+
35
+ return observer;
36
+ }