uikit 3.12.3-dev.ebebb4f57 → 3.13.0

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 (90) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/css/uikit-core-rtl.css +7 -4
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +7 -4
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +7 -4
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +7 -4
  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 +11 -2
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +13 -4
  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 +61 -10
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +28 -15
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +12 -3
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +28 -15
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +11 -2
  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 +12 -20
  33. package/dist/js/components/tooltip.min.js +1 -1
  34. package/dist/js/components/upload.js +1 -1
  35. package/dist/js/components/upload.min.js +1 -1
  36. package/dist/js/uikit-core.js +360 -365
  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 +376 -379
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/hooks.js +3 -3
  44. package/src/js/api/state.js +14 -39
  45. package/src/js/components/countdown.js +2 -2
  46. package/src/js/components/lightbox.js +1 -1
  47. package/src/js/components/parallax.js +3 -1
  48. package/src/js/components/slider-parallax.js +6 -4
  49. package/src/js/components/slider.js +1 -1
  50. package/src/js/core/accordion.js +6 -3
  51. package/src/js/core/core.js +2 -17
  52. package/src/js/core/cover.js +3 -6
  53. package/src/js/core/drop.js +15 -33
  54. package/src/js/core/form-custom.js +8 -9
  55. package/src/js/core/grid.js +2 -1
  56. package/src/js/core/height-match.js +12 -2
  57. package/src/js/core/height-viewport.js +8 -7
  58. package/src/js/core/icon.js +9 -16
  59. package/src/js/core/img.js +5 -16
  60. package/src/js/core/index.js +0 -1
  61. package/src/js/core/leader.js +7 -13
  62. package/src/js/core/margin.js +16 -1
  63. package/src/js/core/overflow-auto.js +7 -10
  64. package/src/js/core/responsive.js +7 -0
  65. package/src/js/core/scroll.js +6 -2
  66. package/src/js/core/scrollspy-nav.js +19 -16
  67. package/src/js/core/scrollspy.js +5 -11
  68. package/src/js/core/sticky.js +22 -31
  69. package/src/js/core/svg.js +16 -14
  70. package/src/js/core/switcher.js +4 -0
  71. package/src/js/core/toggle.js +28 -20
  72. package/src/js/core/video.js +2 -8
  73. package/src/js/mixin/media.js +28 -8
  74. package/src/js/mixin/parallax.js +2 -1
  75. package/src/js/mixin/position.js +10 -18
  76. package/src/js/mixin/resize.js +11 -0
  77. package/src/js/mixin/scroll.js +32 -0
  78. package/src/js/mixin/slider.js +2 -1
  79. package/src/js/util/class.js +1 -6
  80. package/src/js/util/mouse.js +1 -1
  81. package/src/js/util/observer.js +57 -20
  82. package/src/js/util/selector.js +24 -23
  83. package/src/less/components/modal.less +6 -3
  84. package/src/scss/components/modal.scss +6 -3
  85. package/tests/grid.html +9 -9
  86. package/tests/js/index.js +1 -1
  87. package/tests/slider.html +1 -1
  88. package/tests/slideshow.html +1 -1
  89. package/tests/sticky.html +0 -6
  90. package/src/js/core/gif.js +0 -22
@@ -1,8 +1,9 @@
1
1
  import Class from '../mixin/class';
2
- import { closest, css, dimensions, height, isVisible, toFloat, trigger } from 'uikit-util';
2
+ import Resize from '../mixin/resize';
3
+ import { closest, css, dimensions, height, isVisible } from 'uikit-util';
3
4
 
4
5
  export default {
5
- mixins: [Class],
6
+ mixins: [Class, Resize],
6
7
 
7
8
  props: {
8
9
  selContainer: String,
@@ -26,8 +27,8 @@ export default {
26
27
  },
27
28
  },
28
29
 
29
- connected() {
30
- css(this.$el, 'minHeight', this.minHeight);
30
+ resizeTargets() {
31
+ return [this.container, this.content];
31
32
  },
32
33
 
33
34
  update: {
@@ -37,7 +38,6 @@ export default {
37
38
  }
38
39
 
39
40
  return {
40
- current: toFloat(css(this.$el, 'maxHeight')),
41
41
  max: Math.max(
42
42
  this.minHeight,
43
43
  height(this.container) - (dimensions(this.content).height - height(this.$el))
@@ -45,11 +45,8 @@ export default {
45
45
  };
46
46
  },
47
47
 
48
- write({ current, max }) {
49
- css(this.$el, 'maxHeight', max);
50
- if (Math.round(current) !== Math.round(max)) {
51
- trigger(this.$el, 'resize');
52
- }
48
+ write({ max }) {
49
+ css(this.$el, { minHeight: this.minHeight, maxHeight: max });
53
50
  },
54
51
 
55
52
  events: ['resize'],
@@ -1,8 +1,15 @@
1
+ import Resize from '../mixin/resize';
1
2
  import { addClass, Dimensions, height, isVisible, parent, width } from 'uikit-util';
2
3
 
3
4
  export default {
5
+ mixin: [Resize],
6
+
4
7
  props: ['width', 'height'],
5
8
 
9
+ resizeTargets() {
10
+ return [this.$el, parent(this.$el)];
11
+ },
12
+
6
13
  connected() {
7
14
  addClass(this.$el, 'uk-responsive-width');
8
15
  },
@@ -1,4 +1,4 @@
1
- import { $, escape, scrollIntoView, trigger } from 'uikit-util';
1
+ import { $, scrollIntoView, trigger } from 'uikit-util';
2
2
 
3
3
  export default {
4
4
  props: {
@@ -27,7 +27,11 @@ export default {
27
27
  }
28
28
 
29
29
  e.preventDefault();
30
- this.scrollTo(`#${escape(decodeURIComponent((this.$el.hash || '').substr(1)))}`);
30
+ this.scrollTo(getTargetElement(this.$el));
31
31
  },
32
32
  },
33
33
  };
34
+
35
+ export function getTargetElement(el) {
36
+ return document.getElementById(decodeURIComponent(el.hash).substring(1));
37
+ }
@@ -1,19 +1,21 @@
1
+ import Scroll from '../mixin/scroll';
1
2
  import {
2
3
  $$,
3
- addClass,
4
4
  closest,
5
- escape,
6
5
  getViewport,
7
6
  getViewportClientHeight,
8
7
  hasClass,
9
8
  isVisible,
10
9
  offset,
11
- removeClass,
12
10
  scrollParents,
11
+ toggleClass,
13
12
  trigger,
14
13
  } from 'uikit-util';
14
+ import { getTargetElement } from './scroll';
15
15
 
16
16
  export default {
17
+ mixins: [Scroll],
18
+
17
19
  props: {
18
20
  cls: String,
19
21
  closest: String,
@@ -45,10 +47,6 @@ export default {
45
47
  immediate: true,
46
48
  },
47
49
 
48
- targets() {
49
- return $$(this.links.map((el) => escape(el.hash).substr(1)).join(','));
50
- },
51
-
52
50
  elements({ closest: selector }) {
53
51
  return closest(this.links, selector || '*');
54
52
  },
@@ -57,13 +55,15 @@ export default {
57
55
  update: [
58
56
  {
59
57
  read() {
60
- const { length } = this.targets;
58
+ const targets = this.links.map(getTargetElement).filter(Boolean);
59
+
60
+ const { length } = targets;
61
61
 
62
62
  if (!length || !isVisible(this.$el)) {
63
63
  return false;
64
64
  }
65
65
 
66
- const [scrollElement] = scrollParents(this.targets, /auto|scroll/, true);
66
+ const [scrollElement] = scrollParents(targets, /auto|scroll/, true);
67
67
  const { scrollTop, scrollHeight } = scrollElement;
68
68
  const max = scrollHeight - getViewportClientHeight(scrollElement);
69
69
  let active = false;
@@ -71,15 +71,17 @@ export default {
71
71
  if (scrollTop === max) {
72
72
  active = length - 1;
73
73
  } else {
74
- this.targets.every((el, i) => {
74
+ for (const i in targets) {
75
75
  if (
76
- offset(el).top - offset(getViewport(scrollElement)).top - this.offset <=
76
+ offset(targets[i]).top -
77
+ offset(getViewport(scrollElement)).top -
78
+ this.offset >
77
79
  0
78
80
  ) {
79
- active = i;
80
- return true;
81
+ break;
81
82
  }
82
- });
83
+ active = +i;
84
+ }
83
85
 
84
86
  if (active === false && this.overflow) {
85
87
  active = 0;
@@ -93,8 +95,9 @@ export default {
93
95
  const changed = active !== false && !hasClass(this.elements[active], this.cls);
94
96
 
95
97
  this.links.forEach((el) => el.blur());
96
- removeClass(this.elements, this.cls);
97
- addClass(this.elements[active], this.cls);
98
+ for (const i in this.elements) {
99
+ toggleClass(this.elements[i], this.cls, +i === active);
100
+ }
98
101
 
99
102
  if (changed) {
100
103
  trigger(this.$el, 'active', [active, this.elements[active]]);
@@ -1,3 +1,4 @@
1
+ import Scroll from '../mixin/scroll';
1
2
  import {
2
3
  $$,
3
4
  css,
@@ -13,6 +14,8 @@ import {
13
14
 
14
15
  const stateKey = '_ukScrollspy';
15
16
  export default {
17
+ mixins: [Scroll],
18
+
16
19
  args: 'cls',
17
20
 
18
21
  props: {
@@ -54,23 +57,14 @@ export default {
54
57
 
55
58
  disconnected() {
56
59
  for (const el of this.elements) {
57
- removeClass(el, this.inViewClass, el[stateKey] ? el[stateKey].cls : '');
60
+ removeClass(el, this.inViewClass, el[stateKey]?.cls || '');
58
61
  delete el[stateKey];
59
62
  }
60
63
  },
61
64
 
62
65
  update: [
63
66
  {
64
- read(data) {
65
- // Let child components be applied at least once first
66
- if (!data.update) {
67
- Promise.resolve().then(() => {
68
- this.$emit();
69
- data.update = true;
70
- });
71
- return false;
72
- }
73
-
67
+ read() {
74
68
  for (const el of this.elements) {
75
69
  if (!el[stateKey]) {
76
70
  el[stateKey] = { cls: getData(el, 'uk-scrollspy-class') || this.cls };
@@ -1,5 +1,7 @@
1
1
  import Class from '../mixin/class';
2
2
  import Media from '../mixin/media';
3
+ import Resize from '../mixin/resize';
4
+ import Scroll from '../mixin/scroll';
3
5
  import {
4
6
  $,
5
7
  addClass,
@@ -12,7 +14,6 @@ import {
12
14
  height as getHeight,
13
15
  offset as getOffset,
14
16
  getScrollingElement,
15
- hasClass,
16
17
  isString,
17
18
  isVisible,
18
19
  noop,
@@ -32,7 +33,7 @@ import {
32
33
  } from 'uikit-util';
33
34
 
34
35
  export default {
35
- mixins: [Class, Media],
36
+ mixins: [Class, Media, Resize, Scroll],
36
37
 
37
38
  props: {
38
39
  position: String,
@@ -45,7 +46,6 @@ export default {
45
46
  clsFixed: String,
46
47
  clsBelow: String,
47
48
  selTarget: String,
48
- widthElement: Boolean,
49
49
  showOnUp: Boolean,
50
50
  targetOffset: Number,
51
51
  },
@@ -61,7 +61,6 @@ export default {
61
61
  clsFixed: 'uk-sticky-fixed',
62
62
  clsBelow: 'uk-sticky-below',
63
63
  selTarget: '',
64
- widthElement: false,
65
64
  showOnUp: false,
66
65
  targetOffset: false,
67
66
  },
@@ -70,26 +69,10 @@ export default {
70
69
  selTarget({ selTarget }, $el) {
71
70
  return (selTarget && $(selTarget, $el)) || $el;
72
71
  },
72
+ },
73
73
 
74
- widthElement({ widthElement }, $el) {
75
- return query(widthElement, $el) || this.placeholder;
76
- },
77
-
78
- isActive: {
79
- get() {
80
- return hasClass(this.selTarget, this.clsActive);
81
- },
82
-
83
- set(value) {
84
- if (value && !this.isActive) {
85
- replaceClass(this.selTarget, this.clsInactive, this.clsActive);
86
- trigger(this.$el, 'active');
87
- } else if (!value && !hasClass(this.selTarget, this.clsInactive)) {
88
- replaceClass(this.selTarget, this.clsActive, this.clsInactive);
89
- trigger(this.$el, 'inactive');
90
- }
91
- },
92
- },
74
+ resizeTargets() {
75
+ return document.documentElement;
93
76
  },
94
77
 
95
78
  connected() {
@@ -97,7 +80,7 @@ export default {
97
80
  $('+ .uk-sticky-placeholder', this.$el) ||
98
81
  $('<div class="uk-sticky-placeholder"></div>');
99
82
  this.isFixed = false;
100
- this.isActive = false;
83
+ this.setActive(false);
101
84
  },
102
85
 
103
86
  disconnected() {
@@ -108,7 +91,6 @@ export default {
108
91
 
109
92
  remove(this.placeholder);
110
93
  this.placeholder = null;
111
- this.widthElement = null;
112
94
  },
113
95
 
114
96
  events: [
@@ -203,8 +185,7 @@ export default {
203
185
  topOffset,
204
186
  height,
205
187
  margin,
206
- width: dimensions(isVisible(this.widthElement) ? this.widthElement : this.$el)
207
- .width,
188
+ width: dimensions(referenceElement).width,
208
189
  top: offsetPosition(referenceElement)[0],
209
190
  };
210
191
  },
@@ -218,8 +199,6 @@ export default {
218
199
  after(this.$el, placeholder);
219
200
  placeholder.hidden = true;
220
201
  }
221
-
222
- this.isActive = !!this.isActive; // force self-assign
223
202
  },
224
203
 
225
204
  events: ['resize'],
@@ -336,7 +315,7 @@ export default {
336
315
  },
337
316
 
338
317
  hide() {
339
- this.isActive = false;
318
+ this.setActive(false);
340
319
  removeClass(this.$el, this.clsFixed, this.clsBelow);
341
320
  css(this.$el, { position: '', top: '', width: '' });
342
321
  this.placeholder.hidden = true;
@@ -373,10 +352,22 @@ export default {
373
352
  width,
374
353
  });
375
354
 
376
- this.isActive = active;
355
+ this.setActive(active);
377
356
  toggleClass(this.$el, this.clsBelow, scroll > topOffset + height);
378
357
  addClass(this.$el, this.clsFixed);
379
358
  },
359
+
360
+ setActive(active) {
361
+ const prev = this.active;
362
+ this.active = active;
363
+ if (active) {
364
+ replaceClass(this.selTarget, this.clsInactive, this.clsActive);
365
+ prev !== active && trigger(this.$el, 'active');
366
+ } else {
367
+ replaceClass(this.selTarget, this.clsActive, this.clsInactive);
368
+ prev !== active && trigger(this.$el, 'inactive');
369
+ }
370
+ },
380
371
  },
381
372
  };
382
373
 
@@ -6,10 +6,10 @@ import {
6
6
  attr,
7
7
  includes,
8
8
  isTag,
9
- isVisible,
10
9
  isVoidElement,
11
10
  memoize,
12
11
  noop,
12
+ observeIntersection,
13
13
  once,
14
14
  remove,
15
15
  removeAttr,
@@ -59,10 +59,24 @@ export default {
59
59
  }
60
60
 
61
61
  this.applyAttributes(svg, el);
62
- this.$emit();
62
+
63
63
  return (this.svgEl = svg);
64
64
  }
65
65
  }, noop);
66
+
67
+ if (this.strokeAnimation) {
68
+ this.svg.then((el) => {
69
+ if (this._connected) {
70
+ applyAnimation(el);
71
+ this.registerObserver(
72
+ observeIntersection(el, (records, observer) => {
73
+ applyAnimation(el);
74
+ observer.disconnect();
75
+ })
76
+ );
77
+ }
78
+ });
79
+ }
66
80
  },
67
81
 
68
82
  disconnected() {
@@ -82,18 +96,6 @@ export default {
82
96
  this.svg = null;
83
97
  },
84
98
 
85
- update: {
86
- read() {
87
- return !!(this.strokeAnimation && this.svgEl && isVisible(this.svgEl));
88
- },
89
-
90
- write() {
91
- applyAnimation(this.svgEl);
92
- },
93
-
94
- type: ['resize'],
95
- },
96
-
97
99
  methods: {
98
100
  async getSvg() {
99
101
  if (isTag(this.$el, 'img') && !this.$el.complete && this.$el.loading === 'lazy') {
@@ -13,6 +13,7 @@ import {
13
13
  hasClass,
14
14
  matches,
15
15
  queryAll,
16
+ ready,
16
17
  toggleClass,
17
18
  toNodes,
18
19
  within,
@@ -87,6 +88,9 @@ export default {
87
88
 
88
89
  connected() {
89
90
  this.lazyload(this.$el, this.connects);
91
+
92
+ // check for connects
93
+ ready(() => this.$emit());
90
94
  },
91
95
 
92
96
  events: [
@@ -16,6 +16,7 @@ import {
16
16
  pointerEnter,
17
17
  pointerLeave,
18
18
  queryAll,
19
+ ready,
19
20
  trigger,
20
21
  within,
21
22
  } from 'uikit-util';
@@ -41,13 +42,6 @@ export default {
41
42
  queued: true,
42
43
  },
43
44
 
44
- connected() {
45
- if (!includes(this.mode, 'media') && !isFocusable(this.$el)) {
46
- attr(this.$el, 'tabindex', '0');
47
- }
48
- this.lazyload(this.$el, this.target);
49
- },
50
-
51
45
  computed: {
52
46
  target: {
53
47
  get({ href, target }, $el) {
@@ -63,6 +57,17 @@ export default {
63
57
  },
64
58
  },
65
59
 
60
+ connected() {
61
+ if (!includes(this.mode, 'media') && !isFocusable(this.$el)) {
62
+ attr(this.$el, 'tabindex', '0');
63
+ }
64
+
65
+ this.lazyload(this.$el, this.target);
66
+
67
+ // check for target
68
+ ready(() => this.$emit());
69
+ },
70
+
66
71
  events: [
67
72
  {
68
73
  name: pointerDown,
@@ -189,22 +194,25 @@ export default {
189
194
  }
190
195
  },
191
196
  },
192
- ],
193
197
 
194
- update: {
195
- read() {
196
- return includes(this.mode, 'media') && this.media ? { match: this.matchMedia } : false;
197
- },
198
+ {
199
+ name: 'mediachange',
198
200
 
199
- write({ match }) {
200
- const toggled = this.isToggled(this.target);
201
- if (match ? !toggled : toggled) {
202
- this.toggle();
203
- }
204
- },
201
+ filter() {
202
+ return includes(this.mode, 'media');
203
+ },
205
204
 
206
- events: ['resize'],
207
- },
205
+ el() {
206
+ return this.target;
207
+ },
208
+
209
+ handler(e, mediaObj) {
210
+ if (mediaObj.matches ^ this.isToggled(this.target)) {
211
+ this.toggle();
212
+ }
213
+ },
214
+ },
215
+ ],
208
216
 
209
217
  methods: {
210
218
  async toggle(type) {
@@ -23,13 +23,9 @@ export default {
23
23
  autoplay: true,
24
24
  },
25
25
 
26
- computed: {
27
- inView({ autoplay }) {
28
- return autoplay === 'inview';
29
- },
30
- },
31
-
32
26
  connected() {
27
+ this.inView = this.autoplay === 'inview';
28
+
33
29
  if (this.inView && !hasAttr(this.$el, 'preload')) {
34
30
  this.$el.preload = 'none';
35
31
  }
@@ -60,7 +56,5 @@ export default {
60
56
  play(this.$el);
61
57
  }
62
58
  },
63
-
64
- events: ['resize', 'scroll'],
65
59
  },
66
60
  };
@@ -1,4 +1,13 @@
1
- import { getCssVar, isString, toFloat } from 'uikit-util';
1
+ import {
2
+ getCssVar,
3
+ isString,
4
+ on,
5
+ trigger,
6
+ toFloat,
7
+ startsWith,
8
+ isNumeric,
9
+ createEvent,
10
+ } from 'uikit-util';
2
11
 
3
12
  export default {
4
13
  props: {
@@ -9,17 +18,28 @@ export default {
9
18
  media: false,
10
19
  },
11
20
 
12
- computed: {
13
- matchMedia() {
14
- const media = toMedia(this.media);
15
- return !media || window.matchMedia(media).matches;
16
- },
21
+ connected() {
22
+ const media = toMedia(this.media);
23
+ this.mediaObj = window.matchMedia(media);
24
+ const handler = () => {
25
+ this.matchMedia = this.mediaObj.matches;
26
+ trigger(this.$el, createEvent('mediachange', false, true, [this.mediaObj]));
27
+ };
28
+ this.offMediaObj = on(this.mediaObj, 'change', () => {
29
+ handler();
30
+ this.$emit('resize');
31
+ });
32
+ handler();
33
+ },
34
+
35
+ disconnected() {
36
+ this.offMediaObj?.();
17
37
  },
18
38
  };
19
39
 
20
40
  function toMedia(value) {
21
41
  if (isString(value)) {
22
- if (value[0] === '@') {
42
+ if (startsWith(value, '@')) {
23
43
  const name = `breakpoint-${value.substr(1)}`;
24
44
  value = toFloat(getCssVar(name));
25
45
  } else if (isNaN(value)) {
@@ -27,5 +47,5 @@ function toMedia(value) {
27
47
  }
28
48
  }
29
49
 
30
- return value && !isNaN(value) ? `(min-width: ${value}px)` : false;
50
+ return value && isNumeric(value) ? `(min-width: ${value}px)` : '';
31
51
  }
@@ -1,6 +1,7 @@
1
1
  import Media from '../mixin/media';
2
2
  import { getMaxPathLength } from '../core/svg';
3
3
  import {
4
+ createEvent,
4
5
  css,
5
6
  Dimensions,
6
7
  each,
@@ -255,7 +256,7 @@ function getBackgroundImageDimensions(el) {
255
256
  if (!image.naturalWidth) {
256
257
  image.onload = () => {
257
258
  dimensions[src] = toDimensions(image);
258
- trigger(el, 'load');
259
+ trigger(el, createEvent('load', false));
259
260
  };
260
261
  return toDimensions(image);
261
262
  }
@@ -24,18 +24,10 @@ export default {
24
24
  clsPos: '',
25
25
  },
26
26
 
27
- computed: {
28
- pos({ pos }) {
29
- return pos.split('-').concat('center').slice(0, 2);
30
- },
31
-
32
- dir() {
33
- return this.pos[0];
34
- },
35
-
36
- align() {
37
- return this.pos[1];
38
- },
27
+ connected() {
28
+ this.pos = this.$props.pos.split('-').concat('center').slice(0, 2);
29
+ this.dir = this.pos[0];
30
+ this.align = this.pos[1];
39
31
  },
40
32
 
41
33
  methods: {
@@ -44,6 +36,8 @@ export default {
44
36
 
45
37
  let { offset } = this;
46
38
  const axis = this.getAxis();
39
+ const dir = this.pos[0];
40
+ const align = this.pos[1];
47
41
 
48
42
  if (!isNumeric(offset)) {
49
43
  const node = $(offset);
@@ -56,13 +50,11 @@ export default {
56
50
  const { x, y } = positionAt(
57
51
  element,
58
52
  target,
53
+ axis === 'x' ? `${flipPosition(dir)} ${align}` : `${align} ${flipPosition(dir)}`,
54
+ axis === 'x' ? `${dir} ${align}` : `${align} ${dir}`,
59
55
  axis === 'x'
60
- ? `${flipPosition(this.dir)} ${this.align}`
61
- : `${this.align} ${flipPosition(this.dir)}`,
62
- axis === 'x' ? `${this.dir} ${this.align}` : `${this.align} ${this.dir}`,
63
- axis === 'x'
64
- ? `${this.dir === 'left' ? -offset : offset}`
65
- : ` ${this.dir === 'top' ? -offset : offset}`,
56
+ ? `${dir === 'left' ? -offset : offset}`
57
+ : ` ${dir === 'top' ? -offset : offset}`,
66
58
  null,
67
59
  this.flip,
68
60
  boundary
@@ -0,0 +1,11 @@
1
+ import { observeResize } from 'uikit-util';
2
+
3
+ export default {
4
+ connected() {
5
+ this.registerObserver(
6
+ observeResize(this.$options.resizeTargets?.call(this) || this.$el, () =>
7
+ this.$emit('resize')
8
+ )
9
+ );
10
+ },
11
+ };
@@ -0,0 +1,32 @@
1
+ import { on } from 'uikit-util';
2
+
3
+ export default {
4
+ connected() {
5
+ registerScrollListener(this._uid, () => this.$emit('scroll'));
6
+ },
7
+
8
+ disconnected() {
9
+ unregisterScrollListener(this._uid);
10
+ },
11
+ };
12
+
13
+ const scrollListeners = new Map();
14
+ let unbindScrollListener;
15
+ function registerScrollListener(id, listener) {
16
+ unbindScrollListener =
17
+ unbindScrollListener ||
18
+ on(window, 'scroll', () => scrollListeners.forEach((listener) => listener()), {
19
+ passive: true,
20
+ capture: true,
21
+ });
22
+
23
+ scrollListeners.set(id, listener);
24
+ }
25
+
26
+ function unregisterScrollListener(id) {
27
+ scrollListeners.delete(id);
28
+ if (unbindScrollListener && !scrollListeners.size) {
29
+ unbindScrollListener();
30
+ unbindScrollListener = null;
31
+ }
32
+ }