uikit 3.11.2-dev.92f357b93 → 3.11.2-dev.946d2efea

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 (81) hide show
  1. package/CHANGELOG.md +10 -3
  2. package/dist/css/uikit-core-rtl.css +24 -11
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +24 -11
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +24 -11
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +24 -11
  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 +5 -15
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +5 -15
  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 +9 -10
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +9 -10
  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 +9 -10
  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 +2 -2
  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 +427 -312
  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 +485 -410
  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/icon.js +13 -6
  56. package/src/js/core/img.js +19 -25
  57. package/src/js/core/offcanvas.js +2 -1
  58. package/src/js/core/sticky.js +50 -56
  59. package/src/js/core/switcher.js +11 -3
  60. package/src/js/core/toggle.js +4 -2
  61. package/src/js/core/video.js +13 -1
  62. package/src/js/mixin/lazyload.js +20 -0
  63. package/src/js/mixin/parallax.js +9 -10
  64. package/src/js/mixin/slider.js +0 -6
  65. package/src/js/mixin/slideshow.js +0 -4
  66. package/src/js/mixin/swipe.js +72 -0
  67. package/src/js/mixin/togglable.js +1 -1
  68. package/src/js/util/ajax.js +6 -2
  69. package/src/js/util/dimensions.js +4 -4
  70. package/src/js/util/dom.js +16 -7
  71. package/src/js/util/index.js +1 -0
  72. package/src/js/util/observer.js +36 -0
  73. package/src/less/components/form-range.less +4 -6
  74. package/src/less/components/height.less +3 -0
  75. package/src/less/components/utility.less +6 -3
  76. package/src/scss/components/form-range.scss +4 -6
  77. package/src/scss/components/height.scss +3 -0
  78. package/src/scss/components/utility.scss +6 -3
  79. package/tests/parallax.html +5 -5
  80. package/tests/sticky-parallax.html +10 -10
  81. 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,
@@ -68,14 +68,14 @@ const Icon = {
68
68
  },
69
69
 
70
70
  methods: {
71
- getSvg() {
71
+ async getSvg() {
72
72
  const icon = getIcon(this.icon);
73
73
 
74
74
  if (!icon) {
75
- return Promise.reject('Icon not found.');
75
+ throw 'Icon not found.';
76
76
  }
77
77
 
78
- return Promise.resolve(icon);
78
+ return icon;
79
79
  },
80
80
  },
81
81
  };
@@ -137,9 +137,16 @@ export const Close = {
137
137
  export const Spinner = {
138
138
  extends: IconComponent,
139
139
 
140
- async connected() {
141
- const svg = await this.svg;
142
- svg && this.ratio !== 1 && css($('circle', svg), 'strokeWidth', 1 / this.ratio);
140
+ methods: {
141
+ async getSvg() {
142
+ const icon = await Icon.methods.getSvg.call(this);
143
+
144
+ if (this.ratio !== 1) {
145
+ css($('circle', icon), 'strokeWidth', 1 / this.ratio);
146
+ }
147
+
148
+ return icon;
149
+ },
143
150
  },
144
151
  };
145
152
 
@@ -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
 
@@ -172,7 +164,9 @@ function getImageFromElement(el, src, sources) {
172
164
 
173
165
  wrapInPicture(img, sources);
174
166
  setSourceProps(el, img);
175
- img.onload = () => setSrcAttrs(el, img.currentSrc);
167
+ img.onload = () => {
168
+ setSrcAttrs(el, img.currentSrc);
169
+ };
176
170
  attr(img, 'src', src);
177
171
  return img;
178
172
  }
@@ -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
 
@@ -10,13 +10,12 @@ import {
10
10
  dimensions,
11
11
  fastdom,
12
12
  height as getHeight,
13
+ offset as getOffset,
13
14
  getScrollingElement,
14
15
  hasClass,
15
- isNumeric,
16
16
  isString,
17
17
  isVisible,
18
18
  noop,
19
- offset,
20
19
  offsetPosition,
21
20
  parent,
22
21
  query,
@@ -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 {
@@ -67,21 +67,6 @@ export default {
67
67
  },
68
68
 
69
69
  computed: {
70
- position({ position }, $el) {
71
- return position === 'auto'
72
- ? (this.isFixed ? this.placeholder : $el).offsetHeight > getHeight(window)
73
- ? 'bottom'
74
- : 'top'
75
- : position;
76
- },
77
-
78
- offset({ offset }, $el) {
79
- if (this.position === 'bottom') {
80
- offset += '+100vh-100%';
81
- }
82
- return toPx(offset, 'height', $el);
83
- },
84
-
85
70
  selTarget({ selTarget }, $el) {
86
71
  return (selTarget && $(selTarget, $el)) || $el;
87
72
  },
@@ -134,34 +119,29 @@ export default {
134
119
  return window;
135
120
  },
136
121
 
122
+ filter() {
123
+ return this.targetOffset !== false;
124
+ },
125
+
137
126
  handler() {
138
- if (!(this.targetOffset !== false && location.hash && scrollTop(window) > 0)) {
127
+ if (!location.hash || scrollTop(window) === 0) {
139
128
  return;
140
129
  }
141
130
 
142
- const target = $(location.hash);
143
-
144
- if (target) {
145
- fastdom.read(() => {
146
- const { top } = offset(target);
147
- const elTop = offset(this.$el).top;
148
- const elHeight = this.$el.offsetHeight;
149
-
150
- if (
151
- this.isFixed &&
152
- elTop + elHeight >= top &&
153
- elTop <= top + target.offsetHeight
154
- ) {
155
- scrollTop(
156
- window,
157
- top -
158
- elHeight -
159
- (isNumeric(this.targetOffset) ? this.targetOffset : 0) -
160
- this.offset
161
- );
162
- }
163
- });
164
- }
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
+ });
165
145
  },
166
146
  },
167
147
  ],
@@ -177,35 +157,49 @@ export default {
177
157
 
178
158
  const hide = this.isActive && types.has('resize');
179
159
  if (hide) {
160
+ css(this.selTarget, 'transition', '0s');
180
161
  this.hide();
181
162
  }
182
163
 
183
164
  if (!this.isActive) {
184
- height = this.$el.offsetHeight;
165
+ height = getOffset(this.$el).height;
185
166
  margin = css(this.$el, 'margin');
186
167
  }
187
168
 
188
169
  if (hide) {
189
170
  this.show();
171
+ fastdom.write(() => css(this.selTarget, 'transition', ''));
190
172
  }
191
173
 
192
- const overflow = Math.max(0, height + this.offset - getHeight(window));
193
-
194
174
  const referenceElement = this.isFixed ? this.placeholder : this.$el;
195
- const topOffset = offset(referenceElement).top;
196
- const offsetParentTop = offset(referenceElement.offsetParent).top;
175
+ const windowHeight = getHeight(window);
176
+
177
+ let position = this.position;
178
+ if (position === 'auto' && height > windowHeight) {
179
+ position = 'bottom';
180
+ }
181
+
182
+ let offset = toPx(this.offset, 'height', referenceElement);
183
+ if (position === 'bottom') {
184
+ offset += windowHeight - height;
185
+ }
186
+
187
+ const overflow = Math.max(0, height + offset - windowHeight);
188
+ const topOffset = getOffset(referenceElement).top;
189
+ const offsetParentTop = getOffset(referenceElement.offsetParent).top;
197
190
 
198
191
  const top = parseProp(this.top, this.$el, topOffset);
199
192
  const bottom = parseProp(this.bottom, this.$el, topOffset + height, true);
200
193
 
201
- const start = Math.max(top, topOffset) - this.offset;
194
+ const start = Math.max(top, topOffset) - offset;
202
195
  const end = bottom
203
- ? bottom - this.$el.offsetHeight + overflow - this.offset
204
- : getScrollingElement(this.$el).scrollHeight - getHeight(window);
196
+ ? bottom - getOffset(this.$el).height + overflow - offset
197
+ : getScrollingElement(this.$el).scrollHeight - windowHeight;
205
198
 
206
199
  return {
207
200
  start,
208
201
  end,
202
+ offset,
209
203
  overflow,
210
204
  topOffset,
211
205
  offsetParentTop,
@@ -322,7 +316,7 @@ export default {
322
316
  }
323
317
  } else if (this.isFixed) {
324
318
  this.update();
325
- } else if (this.animation) {
319
+ } else if (this.animation && scroll > topOffset) {
326
320
  Animation.cancel(this.$el);
327
321
  this.show();
328
322
  Animation.in(this.$el, this.animation).catch(noop);
@@ -350,33 +344,33 @@ export default {
350
344
  },
351
345
 
352
346
  update() {
353
- const {
347
+ let {
354
348
  width,
355
349
  scroll = 0,
356
350
  overflow,
357
351
  overflowScroll = 0,
358
352
  start,
359
353
  end,
354
+ offset,
360
355
  topOffset,
361
356
  height,
362
357
  offsetParentTop,
363
358
  } = this._data;
364
359
  const active = start !== 0 || scroll > start;
365
- let top = this.offset;
366
360
  let position = 'fixed';
367
361
 
368
362
  if (scroll > end) {
369
- top = end + this.offset - offsetParentTop;
363
+ offset += end - offsetParentTop;
370
364
  position = 'absolute';
371
365
  }
372
366
 
373
367
  if (overflow) {
374
- top -= overflowScroll;
368
+ offset -= overflowScroll;
375
369
  }
376
370
 
377
371
  css(this.$el, {
378
372
  position,
379
- top: `${top}px`,
373
+ top: `${offset}px`,
380
374
  width,
381
375
  });
382
376
 
@@ -397,7 +391,7 @@ function parseProp(value, el, propOffset, padding) {
397
391
  } else {
398
392
  const refElement = value === true ? parent(el) : query(value, el);
399
393
  return (
400
- offset(refElement).bottom -
394
+ getOffset(refElement).bottom -
401
395
  (padding && refElement && within(el, refElement)
402
396
  ? toFloat(css(refElement, 'paddingBottom'))
403
397
  : 0)
@@ -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: {
@@ -135,7 +137,7 @@ export default {
135
137
  name: 'keydown',
136
138
 
137
139
  filter() {
138
- return includes(this.mode, 'click') && isTag(this.$el, 'input');
140
+ return includes(this.mode, 'click') && !isTag(this.$el, 'input');
139
141
  },
140
142
 
141
143
  handler(e) {
@@ -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
+ };