uikit 3.15.15-dev.cc41b76e3 → 3.15.15-dev.f41a7c271

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 (53) hide show
  1. package/CHANGELOG.md +9 -2
  2. package/dist/css/uikit-core-rtl.css +1 -1
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +1 -1
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +1 -1
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +1 -1
  9. package/dist/css/uikit.min.css +1 -1
  10. package/dist/js/components/countdown.js +1 -1
  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 -2
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +5 -2
  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 -1
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +1 -1
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +1 -1
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +1 -1
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +1 -1
  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 +1 -1
  35. package/dist/js/components/upload.min.js +1 -1
  36. package/dist/js/uikit-core.js +213 -172
  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 +221 -172
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/images/components/navbar-toggle-icon.svg +1 -1
  44. package/src/js/components/parallax.js +9 -1
  45. package/src/js/core/drop.js +5 -3
  46. package/src/js/core/img.js +3 -11
  47. package/src/js/core/scrollspy.js +3 -10
  48. package/src/js/core/sticky.js +56 -19
  49. package/src/js/mixin/modal.js +4 -1
  50. package/src/js/util/dimensions.js +25 -1
  51. package/tests/image.html +6 -12
  52. package/tests/scrollspy.html +4 -10
  53. package/src/js/mixin/style.js +0 -11
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uikit",
3
3
  "title": "UIkit",
4
4
  "description": "UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.",
5
- "version": "3.15.15-dev.cc41b76e3",
5
+ "version": "3.15.15-dev.f41a7c271",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -3,7 +3,7 @@
3
3
 
4
4
  .uk-navbar-toggle-animate svg > [class*='line-'] {
5
5
  transition: 0.2s ease-in-out;
6
- transition-property: transform, opacity,;
6
+ transition-property: transform, opacity;
7
7
  transform-origin: center;
8
8
  opacity: 1;
9
9
  }
@@ -1,7 +1,7 @@
1
1
  import Resize from '../mixin/resize';
2
2
  import Scroll from '../mixin/scroll';
3
3
  import Parallax from '../mixin/parallax';
4
- import { css, parent, query, scrolledOver, toPx } from 'uikit-util';
4
+ import { css, isVisible, parent, query, scrolledOver, toPx } from 'uikit-util';
5
5
 
6
6
  export default {
7
7
  mixins: [Parallax, Resize, Scroll],
@@ -41,12 +41,20 @@ export default {
41
41
  },
42
42
  },
43
43
 
44
+ resizeTargets() {
45
+ return [this.$el, this.target];
46
+ },
47
+
44
48
  update: {
45
49
  read({ percent }, types) {
46
50
  if (!types.has('scroll')) {
47
51
  percent = false;
48
52
  }
49
53
 
54
+ if (!isVisible(this.$el)) {
55
+ return false;
56
+ }
57
+
50
58
  if (!this.matchMedia) {
51
59
  return;
52
60
  }
@@ -1,7 +1,6 @@
1
1
  import Container from '../mixin/container';
2
2
  import Lazyload from '../mixin/lazyload';
3
3
  import Position from '../mixin/position';
4
- import Style from '../mixin/style';
5
4
  import Togglable from '../mixin/togglable';
6
5
  import {
7
6
  addClass,
@@ -35,7 +34,7 @@ import { isSameSiteAnchor, preventBackgroundScroll, preventOverscroll } from '..
35
34
  export let active;
36
35
 
37
36
  export default {
38
- mixins: [Container, Lazyload, Position, Style, Togglable],
37
+ mixins: [Container, Lazyload, Position, Togglable],
39
38
 
40
39
  args: 'pos',
41
40
 
@@ -116,6 +115,8 @@ export default {
116
115
  attr(this.targetEl, 'aria-haspopup', true);
117
116
  this.lazyload(this.targetEl);
118
117
  }
118
+
119
+ this._style = (({ width, height }) => ({ width, height }))(this.$el.style);
119
120
  },
120
121
 
121
122
  disconnected() {
@@ -123,6 +124,7 @@ export default {
123
124
  this.hide(false);
124
125
  active = null;
125
126
  }
127
+ css(this.$el, this._style);
126
128
  },
127
129
 
128
130
  events: [
@@ -424,7 +426,7 @@ export default {
424
426
 
425
427
  position() {
426
428
  removeClass(this.$el, `${this.clsDrop}-stack`);
427
- attr(this.$el, 'style', this._style);
429
+ css(this.$el, this._style);
428
430
 
429
431
  // Ensure none positioned element does not generate scrollbars
430
432
  this.$el.hidden = true;
@@ -19,7 +19,6 @@ import {
19
19
  queryAll,
20
20
  removeAttr,
21
21
  startsWith,
22
- toPx,
23
22
  trigger,
24
23
  } from 'uikit-util';
25
24
 
@@ -31,8 +30,7 @@ export default {
31
30
  props: {
32
31
  dataSrc: String,
33
32
  sources: String,
34
- offsetTop: String,
35
- offsetLeft: String,
33
+ margin: String,
36
34
  target: String,
37
35
  loading: String,
38
36
  },
@@ -40,8 +38,7 @@ export default {
40
38
  data: {
41
39
  dataSrc: '',
42
40
  sources: false,
43
- offsetTop: '50vh',
44
- offsetLeft: '50vw',
41
+ margin: '50%',
45
42
  target: false,
46
43
  loading: 'lazy',
47
44
  },
@@ -72,12 +69,7 @@ export default {
72
69
  this.load();
73
70
  observer.disconnect();
74
71
  },
75
- {
76
- rootMargin: `${toPx(this.offsetTop, 'height')}px ${toPx(
77
- this.offsetLeft,
78
- 'width'
79
- )}px`,
80
- }
72
+ { rootMargin: this.margin }
81
73
  )
82
74
  );
83
75
  },
@@ -10,7 +10,6 @@ import {
10
10
  removeClass,
11
11
  removeClasses,
12
12
  toggleClass,
13
- toPx,
14
13
  trigger,
15
14
  } from 'uikit-util';
16
15
 
@@ -23,8 +22,7 @@ export default {
23
22
  cls: String,
24
23
  target: String,
25
24
  hidden: Boolean,
26
- offsetTop: Number,
27
- offsetLeft: Number,
25
+ margin: String,
28
26
  repeat: Boolean,
29
27
  delay: Number,
30
28
  },
@@ -33,8 +31,7 @@ export default {
33
31
  cls: '',
34
32
  target: false,
35
33
  hidden: true,
36
- offsetTop: 0,
37
- offsetLeft: 0,
34
+ margin: '-1px',
38
35
  repeat: false,
39
36
  delay: 0,
40
37
  inViewClass: 'uk-scrollspy-inview',
@@ -85,11 +82,7 @@ export default {
85
82
 
86
83
  this.$emit();
87
84
  },
88
- {
89
- rootMargin: `${toPx(this.offsetTop, 'height') - 1}px ${
90
- toPx(this.offsetLeft, 'width') - 1
91
- }px`,
92
- },
85
+ { rootMargin: this.margin },
93
86
  false
94
87
  )
95
88
  );
@@ -7,6 +7,7 @@ import {
7
7
  addClass,
8
8
  after,
9
9
  Animation,
10
+ before,
10
11
  clamp,
11
12
  css,
12
13
  height as getHeight,
@@ -94,6 +95,7 @@ export default {
94
95
  this.hide();
95
96
  removeClass(this.selTarget, this.clsInactive);
96
97
  }
98
+ css(this.$el, { position: '', top: '' });
97
99
 
98
100
  remove(this.placeholder);
99
101
  this.placeholder = null;
@@ -147,7 +149,7 @@ export default {
147
149
 
148
150
  update: [
149
151
  {
150
- read({ height, width, margin }, types) {
152
+ read({ height, width, margin, sticky }, types) {
151
153
  this.inactive = !this.matchMedia || !isVisible(this.$el);
152
154
 
153
155
  if (this.inactive) {
@@ -171,6 +173,7 @@ export default {
171
173
  }
172
174
 
173
175
  const windowHeight = getHeight(window);
176
+ const maxScrollHeight = document.scrollingElement.scrollHeight - windowHeight;
174
177
 
175
178
  let position = this.position;
176
179
  if (this.overflowFlip && height > windowHeight) {
@@ -178,7 +181,7 @@ export default {
178
181
  }
179
182
 
180
183
  const referenceElement = this.isFixed ? this.placeholder : this.$el;
181
- let offset = toPx(this.offset, 'height', referenceElement);
184
+ let offset = toPx(this.offset, 'height', sticky ? this.$el : referenceElement);
182
185
  if (position === 'bottom' && (height < windowHeight || this.overflowFlip)) {
183
186
  offset += windowHeight - height;
184
187
  }
@@ -187,6 +190,7 @@ export default {
187
190
  ? 0
188
191
  : Math.max(0, height + offset - windowHeight);
189
192
  const topOffset = getOffset(referenceElement).top;
193
+ const elHeight = getOffset(this.$el).height;
190
194
 
191
195
  const start =
192
196
  (this.start === false
@@ -194,11 +198,23 @@ export default {
194
198
  : parseProp(this.start, this.$el, topOffset)) - offset;
195
199
  const end =
196
200
  this.end === false
197
- ? document.scrollingElement.scrollHeight - windowHeight
198
- : parseProp(this.end, this.$el, topOffset + height, true) -
199
- getOffset(this.$el).height +
200
- overflow -
201
- offset;
201
+ ? maxScrollHeight
202
+ : Math.min(
203
+ maxScrollHeight,
204
+ parseProp(this.end, this.$el, topOffset + height, true) -
205
+ elHeight -
206
+ offset +
207
+ overflow
208
+ );
209
+
210
+ sticky =
211
+ !this.showOnUp &&
212
+ start + offset === topOffset &&
213
+ end ===
214
+ Math.min(
215
+ maxScrollHeight,
216
+ parseProp('!*', this.$el, 0, true) - elHeight - offset + overflow
217
+ );
202
218
 
203
219
  return {
204
220
  start,
@@ -210,18 +226,23 @@ export default {
210
226
  width,
211
227
  margin,
212
228
  top: offsetPosition(referenceElement)[0],
229
+ sticky,
213
230
  };
214
231
  },
215
232
 
216
- write({ height, width, margin }) {
233
+ write({ height, width, margin, offset, sticky }) {
234
+ if (sticky) {
235
+ height = width = margin = 0;
236
+ css(this.$el, { position: 'sticky', top: offset });
237
+ }
217
238
  const { placeholder } = this;
218
239
 
219
240
  css(placeholder, { height, width, margin });
220
241
 
221
242
  if (!within(placeholder, document)) {
222
- after(this.$el, placeholder);
223
243
  placeholder.hidden = true;
224
244
  }
245
+ (sticky ? before : after)(this.$el, placeholder);
225
246
  },
226
247
 
227
248
  events: ['resize'],
@@ -338,9 +359,19 @@ export default {
338
359
  },
339
360
 
340
361
  hide() {
362
+ const { offset, sticky } = this._data;
341
363
  this.setActive(false);
342
364
  removeClass(this.$el, this.clsFixed, this.clsBelow);
343
- css(this.$el, { position: '', top: '', width: '' });
365
+ if (sticky) {
366
+ css(this.$el, 'top', offset);
367
+ } else {
368
+ css(this.$el, {
369
+ position: '',
370
+ top: '',
371
+ width: '',
372
+ marginTop: '',
373
+ });
374
+ }
344
375
  this.placeholder.hidden = true;
345
376
  this.isFixed = false;
346
377
  },
@@ -357,24 +388,30 @@ export default {
357
388
  topOffset,
358
389
  height,
359
390
  offsetParentTop,
391
+ sticky,
360
392
  } = this._data;
361
393
  const active = start !== 0 || scroll > start;
362
- let position = 'fixed';
363
394
 
364
- if (scroll > end) {
365
- offset += end - offsetParentTop;
366
- position = 'absolute';
395
+ if (!sticky) {
396
+ let position = 'fixed';
397
+
398
+ if (scroll > end) {
399
+ offset += end - offsetParentTop;
400
+ position = 'absolute';
401
+ }
402
+
403
+ css(this.$el, {
404
+ position,
405
+ width,
406
+ });
407
+ css(this.$el, 'marginTop', 0, 'important');
367
408
  }
368
409
 
369
410
  if (overflow) {
370
411
  offset -= overflowScroll;
371
412
  }
372
413
 
373
- css(this.$el, {
374
- position,
375
- top: `${offset}px`,
376
- width,
377
- });
414
+ css(this.$el, 'top', offset);
378
415
 
379
416
  this.setActive(active);
380
417
  toggleClass(this.$el, this.clsBelow, scroll > topOffset + height);
@@ -304,7 +304,10 @@ function toMs(time) {
304
304
 
305
305
  export function preventOverscroll(el) {
306
306
  if (CSS.supports('overscroll-behavior', 'contain')) {
307
- const elements = filterChildren(el, (child) => /auto|scroll/.test(css(child, 'overflow')));
307
+ const elements = [
308
+ el,
309
+ ...filterChildren(el, (child) => /auto|scroll/.test(css(child, 'overflow'))),
310
+ ];
308
311
  css(elements, 'overscrollBehavior', 'contain');
309
312
  return () => css(elements, 'overscrollBehavior', '');
310
313
  }
@@ -1,4 +1,6 @@
1
+ import { on } from './event';
1
2
  import { css } from './style';
3
+ import { $, append, remove } from './dom';
2
4
  import {
3
5
  each,
4
6
  isDocument,
@@ -180,7 +182,7 @@ export function toPx(value, property = 'width', element = window, offsetDim = fa
180
182
  if (unit) {
181
183
  value = percent(
182
184
  unit === 'vh'
183
- ? height(toWindow(element))
185
+ ? getViewportHeight()
184
186
  : unit === 'vw'
185
187
  ? width(toWindow(element))
186
188
  : offsetDim
@@ -202,3 +204,25 @@ const parseUnit = memoize((str) => (str.match(unitRe) || [])[0]);
202
204
  function percent(base, value) {
203
205
  return (base * toFloat(value)) / 100;
204
206
  }
207
+
208
+ let vh;
209
+ let vhEl;
210
+
211
+ function getViewportHeight() {
212
+ if (vh) {
213
+ return vh;
214
+ }
215
+ if (!vhEl) {
216
+ vhEl = $('<div>');
217
+ css(vhEl, {
218
+ height: '100vh',
219
+ position: 'fixed',
220
+ });
221
+ on(window, 'resize', () => (vh = null));
222
+ }
223
+
224
+ append(document.body, vhEl);
225
+ vh = vhEl.clientHeight;
226
+ remove(vhEl);
227
+ return vh;
228
+ }
package/tests/image.html CHANGED
@@ -17,7 +17,7 @@
17
17
  <div class="uk-height-large uk-background-cover uk-margin-medium uk-flex uk-flex-center uk-flex-middle uk-light" data-src="https://images.unsplash.com/photo-1495321308589-43affb814eee?fit=crop&w=1200&h=450&q=80" uk-img="loading: eager">
18
18
  <h1>Background Image Loading Eager</h1>
19
19
  </div>
20
-
20
+
21
21
  <h2>Loading Lazy Attribute</h2>
22
22
 
23
23
  <div class="uk-child-width-1-2@m" uk-grid>
@@ -265,7 +265,7 @@
265
265
  sizes="(min-width: 1200px) 1200px, 100vw" uk-img>
266
266
  <h1>Background Picture with Srcset</h1>
267
267
  </div>
268
-
268
+
269
269
  <div class="uk-height-large uk-background-cover uk-margin-medium uk-flex uk-flex-center uk-flex-middle"
270
270
  sources="[{&quot;srcset&quot;: &quot;images/image-type.avif&quot;,
271
271
  &quot;type&quot;: &quot;image\/avif&quot;
@@ -491,7 +491,7 @@
491
491
  width="746" height="498" alt="" uk-img>
492
492
  </div>
493
493
  </div>
494
-
494
+
495
495
  <div class="uk-child-width-1-2@m" uk-grid>
496
496
  <div>
497
497
 
@@ -621,16 +621,10 @@
621
621
  <td>Enable lazy/eager loading. Set to `eager` for images within the first visible viewport.</td>
622
622
  </tr>
623
623
  <tr>
624
- <td><code>offsetTop</code></td>
625
- <td>String</td>
626
- <td>'50vh'</td>
627
- <td>The offset increases the viewport's bounding box vertically, before computing an intersection with the image.</td>
628
- </tr>
629
- <tr>
630
- <td><code>offsetLeft</code></td>
624
+ <td><code>margin</code></td>
631
625
  <td>String</td>
632
- <td>0</td>
633
- <td>The offset increases the viewport's bounding box horizontally, before computing an intersection with the image.</td>
626
+ <td>'50%'</td>
627
+ <td>The margin increases the viewport's bounding box, before computing an intersection with the image. (Must be px or % units)</td>
634
628
  </tr>
635
629
  <tr>
636
630
  <td><code>target</code></td>
@@ -513,16 +513,10 @@
513
513
  <td>Hides the element while out of view.</td>
514
514
  </tr>
515
515
  <tr>
516
- <td><code>offset-top</code></td>
517
- <td>Number</td>
518
- <td>0</td>
519
- <td>Top offset before triggering in view.</td>
520
- </tr>
521
- <tr>
522
- <td><code>offset-left</code></td>
523
- <td>Number</td>
524
- <td>0</td>
525
- <td>Left offset before triggering in view.</td>
516
+ <td><code>margin</code></td>
517
+ <td>String</td>
518
+ <td>'-1px'</td>
519
+ <td>The margin is added to the viewport's bounding box, before computing an intersection with the element. (Must be px or % units)</td>
526
520
  </tr>
527
521
  <tr>
528
522
  <td><code>repeat</code></td>
@@ -1,11 +0,0 @@
1
- import { attr } from 'uikit-util';
2
-
3
- export default {
4
- beforeConnect() {
5
- this._style = attr(this.$el, 'style');
6
- },
7
-
8
- disconnected() {
9
- attr(this.$el, 'style', this._style);
10
- },
11
- };