uikit 3.11.2-dev.21a5b7139 → 3.11.2-dev.29f2881ed

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 (146) hide show
  1. package/CHANGELOG.md +36 -19
  2. package/dist/css/uikit-core-rtl.css +86 -185
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +86 -185
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +88 -191
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +88 -191
  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 +10 -14
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +31 -60
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +34 -64
  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 +110 -72
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +110 -72
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +75 -28
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +110 -72
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +57 -21
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +16 -20
  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 +10 -14
  35. package/dist/js/components/upload.min.js +1 -1
  36. package/dist/js/uikit-core.js +340 -337
  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 +584 -518
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/component.js +2 -11
  44. package/src/js/api/hooks.js +1 -1
  45. package/src/js/api/state.js +3 -3
  46. package/src/js/components/countdown.js +2 -2
  47. package/src/js/components/filter.js +2 -3
  48. package/src/js/components/internal/lightbox-animations.js +4 -3
  49. package/src/js/components/internal/slider-preload.js +37 -0
  50. package/src/js/components/internal/slider-transitioner.js +2 -2
  51. package/src/js/components/internal/slideshow-animations.js +4 -3
  52. package/src/js/components/lightbox-panel.js +34 -58
  53. package/src/js/components/lightbox.js +3 -4
  54. package/src/js/components/slider.js +30 -11
  55. package/src/js/components/slideshow.js +8 -1
  56. package/src/js/components/sortable.js +8 -8
  57. package/src/js/components/upload.js +9 -13
  58. package/src/js/core/accordion.js +3 -3
  59. package/src/js/core/alert.js +1 -2
  60. package/src/js/core/height-match.js +3 -3
  61. package/src/js/core/icon.js +13 -6
  62. package/src/js/core/img.js +134 -115
  63. package/src/js/core/margin.js +11 -13
  64. package/src/js/core/modal.js +1 -2
  65. package/src/js/core/navbar.js +5 -5
  66. package/src/js/core/scrollspy.js +6 -6
  67. package/src/js/core/sticky.js +34 -35
  68. package/src/js/core/svg.js +10 -6
  69. package/src/js/core/toggle.js +4 -3
  70. package/src/js/mixin/internal/animate-slide.js +9 -12
  71. package/src/js/mixin/parallax.js +110 -72
  72. package/src/js/mixin/slider-drag.js +3 -3
  73. package/src/js/mixin/slider-nav.js +2 -2
  74. package/src/js/mixin/slider.js +8 -16
  75. package/src/js/mixin/slideshow.js +2 -2
  76. package/src/js/mixin/togglable.js +1 -2
  77. package/src/js/util/ajax.js +15 -14
  78. package/src/js/util/animation.js +7 -12
  79. package/src/js/util/attr.js +14 -12
  80. package/src/js/util/dimensions.js +4 -4
  81. package/src/js/util/dom.js +23 -32
  82. package/src/js/util/lang.js +7 -6
  83. package/src/js/util/options.js +2 -11
  84. package/src/js/util/player.js +5 -4
  85. package/src/js/util/position.js +2 -2
  86. package/src/js/util/selector.js +12 -18
  87. package/src/js/util/style.js +4 -4
  88. package/src/less/components/base.less +10 -33
  89. package/src/less/components/form-range.less +48 -95
  90. package/src/less/components/form.less +0 -1
  91. package/src/less/components/height.less +3 -0
  92. package/src/less/components/leader.less +0 -1
  93. package/src/less/components/lightbox.less +0 -1
  94. package/src/less/components/modal.less +3 -7
  95. package/src/less/components/progress.less +14 -36
  96. package/src/less/components/slider.less +0 -3
  97. package/src/less/components/slideshow.less +0 -3
  98. package/src/less/components/text.less +16 -32
  99. package/src/scss/components/base.scss +10 -33
  100. package/src/scss/components/form-range.scss +48 -95
  101. package/src/scss/components/form.scss +0 -1
  102. package/src/scss/components/height.scss +3 -0
  103. package/src/scss/components/leader.scss +0 -1
  104. package/src/scss/components/lightbox.scss +0 -1
  105. package/src/scss/components/modal.scss +3 -7
  106. package/src/scss/components/progress.scss +14 -36
  107. package/src/scss/components/slider.scss +0 -3
  108. package/src/scss/components/slideshow.scss +0 -3
  109. package/src/scss/components/text.scss +16 -32
  110. package/src/scss/mixins-theme.scss +1 -1
  111. package/src/scss/mixins.scss +1 -1
  112. package/src/scss/variables-theme.scss +3 -3
  113. package/src/scss/variables.scss +3 -3
  114. package/tests/align.html +10 -10
  115. package/tests/animation.html +2 -2
  116. package/tests/article.html +2 -2
  117. package/tests/base.html +3 -3
  118. package/tests/card.html +10 -10
  119. package/tests/column.html +3 -3
  120. package/tests/comment.html +9 -9
  121. package/tests/dotnav.html +3 -3
  122. package/tests/image.html +296 -64
  123. package/tests/images/image-type.avif +0 -0
  124. package/tests/images/image-type.jpeg +0 -0
  125. package/tests/images/image-type.webp +0 -0
  126. package/tests/index.html +8 -8
  127. package/tests/lightbox.html +10 -10
  128. package/tests/marker.html +2 -2
  129. package/tests/modal.html +8 -9
  130. package/tests/navbar.html +2 -2
  131. package/tests/overlay.html +7 -7
  132. package/tests/parallax.html +14 -5
  133. package/tests/position.html +12 -12
  134. package/tests/slidenav.html +12 -12
  135. package/tests/slider.html +20 -20
  136. package/tests/sortable.html +1 -1
  137. package/tests/sticky-parallax.html +55 -70
  138. package/tests/svg.html +6 -6
  139. package/tests/table.html +11 -11
  140. package/tests/thumbnav.html +12 -12
  141. package/tests/transition.html +30 -30
  142. package/tests/utility.html +33 -33
  143. package/tests/video.html +1 -1
  144. package/tests/width.html +1 -1
  145. package/src/js/util/promise.js +0 -0
  146. package/tests/images/animated.gif +0 -0
@@ -5,10 +5,12 @@ import {
5
5
  append,
6
6
  attr,
7
7
  includes,
8
+ isTag,
8
9
  isVisible,
9
10
  isVoidElement,
10
11
  memoize,
11
12
  noop,
13
+ once,
12
14
  remove,
13
15
  removeAttr,
14
16
  startsWith,
@@ -94,6 +96,12 @@ export default {
94
96
 
95
97
  methods: {
96
98
  async getSvg() {
99
+ if (isTag(this.$el, 'img') && !this.$el.complete && this.$el.loading === 'lazy') {
100
+ return new Promise((resolve) =>
101
+ once(this.$el, 'load', () => resolve(this.getSvg()))
102
+ );
103
+ }
104
+
97
105
  return parseSVG(await loadSVG(this.src), this.icon) || Promise.reject('SVG not found.');
98
106
  },
99
107
 
@@ -193,7 +201,7 @@ export function getMaxPathLength(el) {
193
201
  }
194
202
 
195
203
  function insertSVG(el, root) {
196
- if (isVoidElement(root) || root.tagName === 'CANVAS') {
204
+ if (isVoidElement(root) || isTag(root, 'canvas')) {
197
205
  root.hidden = true;
198
206
 
199
207
  const next = root.nextElementSibling;
@@ -205,11 +213,7 @@ function insertSVG(el, root) {
205
213
  }
206
214
 
207
215
  function equals(el, other) {
208
- return isSVG(el) && isSVG(other) && innerHTML(el) === innerHTML(other);
209
- }
210
-
211
- function isSVG(el) {
212
- return el?.tagName === 'svg';
216
+ return isTag(el, 'svg') && isTag(other, 'svg') && innerHTML(el) === innerHTML(other);
213
217
  }
214
218
 
215
219
  function innerHTML(el) {
@@ -7,6 +7,7 @@ import {
7
7
  includes,
8
8
  isBoolean,
9
9
  isFocusable,
10
+ isTag,
10
11
  isTouch,
11
12
  matches,
12
13
  once,
@@ -134,7 +135,7 @@ export default {
134
135
  name: 'keydown',
135
136
 
136
137
  filter() {
137
- return includes(this.mode, 'click') && this.$el.tagName !== 'INPUT';
138
+ return includes(this.mode, 'click') && !isTag(this.$el, 'input');
138
139
  },
139
140
 
140
141
  handler(e) {
@@ -216,10 +217,10 @@ export default {
216
217
  const leaving = this.target.filter((el) => hasClass(el, this.clsLeave));
217
218
 
218
219
  if (leaving.length) {
219
- this.target.forEach((el) => {
220
+ for (const el of this.target) {
220
221
  const isLeaving = includes(leaving, el);
221
222
  this.toggleElement(el, isLeaving, isLeaving);
222
- });
223
+ }
223
224
  return;
224
225
  }
225
226
 
@@ -1,5 +1,4 @@
1
1
  import {
2
- assign,
3
2
  children,
4
3
  css,
5
4
  fastdom,
@@ -44,7 +43,7 @@ export default function (action, target, duration) {
44
43
 
45
44
  // Reset to previous state
46
45
  nodes.forEach((el, i) => propsFrom[i] && css(el, propsFrom[i]));
47
- css(target, assign({ display: 'block' }, targetProps));
46
+ css(target, { display: 'block', ...targetProps });
48
47
 
49
48
  // Start transitions on next frame
50
49
  requestAnimationFrame(() => {
@@ -76,16 +75,14 @@ function getProps(el, opacity) {
76
75
  const zIndex = css(el, 'zIndex');
77
76
 
78
77
  return isVisible(el)
79
- ? assign(
80
- {
81
- display: '',
82
- opacity: opacity ? css(el, 'opacity') : '0',
83
- pointerEvents: 'none',
84
- position: 'absolute',
85
- zIndex: zIndex === 'auto' ? index(el) : zIndex,
86
- },
87
- getPositionWithMargin(el)
88
- )
78
+ ? {
79
+ display: '',
80
+ opacity: opacity ? css(el, 'opacity') : '0',
81
+ pointerEvents: 'none',
82
+ position: 'absolute',
83
+ zIndex: zIndex === 'auto' ? index(el) : zIndex,
84
+ ...getPositionWithMargin(el),
85
+ }
89
86
  : false;
90
87
  }
91
88
 
@@ -4,11 +4,11 @@ import {
4
4
  css,
5
5
  Dimensions,
6
6
  each,
7
+ findIndex,
7
8
  isNumber,
8
9
  isString,
9
10
  isUndefined,
10
11
  noop,
11
- startsWith,
12
12
  toFloat,
13
13
  toPx,
14
14
  trigger,
@@ -79,39 +79,35 @@ export default {
79
79
  },
80
80
  };
81
81
 
82
- function transformFn(prop, el, steps) {
83
- const unit = getUnit(steps) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
82
+ function transformFn(prop, el, stops) {
83
+ const unit = getUnit(stops) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
84
+ let transformFn;
84
85
 
85
86
  if (prop === 'x' || prop === 'y') {
86
87
  prop = `translate${ucfirst(prop)}`;
88
+ transformFn = (stop) => toFloat(toFloat(stop).toFixed(unit === 'px' ? 0 : 6));
87
89
  }
88
90
 
89
- steps = steps.map(toFloat);
90
-
91
- if (steps.length === 1) {
92
- steps.unshift(prop === 'scale' ? 1 : 0);
91
+ if (stops.length === 1) {
92
+ stops.unshift(prop === 'scale' ? 1 : 0);
93
93
  }
94
94
 
95
- return (css, percent) => {
96
- let value = getValue(steps, percent);
95
+ stops = parseStops(stops, transformFn);
97
96
 
98
- if (startsWith(prop, 'translate')) {
99
- value = toFloat(value).toFixed(unit === 'px' ? 0 : 6);
100
- }
101
-
102
- css.transform += ` ${prop}(${value}${unit})`;
97
+ return (css, percent) => {
98
+ css.transform += ` ${prop}(${getValue(stops, percent)}${unit})`;
103
99
  };
104
100
  }
105
101
 
106
- function colorFn(prop, el, steps) {
107
- if (steps.length === 1) {
108
- steps.unshift(getCssValue(el, prop, ''));
102
+ function colorFn(prop, el, stops) {
103
+ if (stops.length === 1) {
104
+ stops.unshift(getCssValue(el, prop, ''));
109
105
  }
110
106
 
111
- steps = steps.map((step) => parseColor(el, step));
107
+ stops = parseStops(stops, (stop) => parseColor(el, stop));
112
108
 
113
109
  return (css, percent) => {
114
- const [start, end, p] = getStep(steps, percent);
110
+ const [start, end, p] = getStop(stops, percent);
115
111
  const value = start
116
112
  .map((value, i) => {
117
113
  value += p * (end[i] - value);
@@ -131,85 +127,83 @@ function parseColor(el, color) {
131
127
  .map(toFloat);
132
128
  }
133
129
 
134
- function filterFn(prop, el, steps) {
135
- if (steps.length === 1) {
136
- steps.unshift(0);
130
+ function filterFn(prop, el, stops) {
131
+ if (stops.length === 1) {
132
+ stops.unshift(0);
137
133
  }
138
134
 
139
- const unit = getUnit(steps) || { blur: 'px', hue: 'deg' }[prop] || '%';
135
+ const unit = getUnit(stops) || { blur: 'px', hue: 'deg' }[prop] || '%';
140
136
  prop = { fopacity: 'opacity', hue: 'hue-rotate' }[prop] || prop;
141
- steps = steps.map(toFloat);
137
+ stops = parseStops(stops);
142
138
 
143
139
  return (css, percent) => {
144
- const value = getValue(steps, percent);
140
+ const value = getValue(stops, percent);
145
141
  css.filter += ` ${prop}(${value + unit})`;
146
142
  };
147
143
  }
148
144
 
149
- function cssPropFn(prop, el, steps) {
150
- if (steps.length === 1) {
151
- steps.unshift(getCssValue(el, prop, ''));
145
+ function cssPropFn(prop, el, stops) {
146
+ if (stops.length === 1) {
147
+ stops.unshift(getCssValue(el, prop, ''));
152
148
  }
153
149
 
154
- steps = steps.map(toFloat);
150
+ stops = parseStops(stops);
155
151
 
156
152
  return (css, percent) => {
157
- css[prop] = getValue(steps, percent);
153
+ css[prop] = getValue(stops, percent);
158
154
  };
159
155
  }
160
156
 
161
- function strokeFn(prop, el, steps) {
162
- if (steps.length === 1) {
163
- steps.unshift(0);
157
+ function strokeFn(prop, el, stops) {
158
+ if (stops.length === 1) {
159
+ stops.unshift(0);
164
160
  }
165
161
 
166
- const unit = getUnit(steps);
167
- steps = steps.map(toFloat);
162
+ const unit = getUnit(stops);
163
+ const length = getMaxPathLength(el);
164
+ stops = parseStops(stops.reverse(), (stop) => {
165
+ stop = toFloat(stop);
166
+ return unit === '%' ? (stop * length) / 100 : stop;
167
+ });
168
168
 
169
- if (!steps.some((step) => step)) {
169
+ if (!stops.some(([value]) => value)) {
170
170
  return noop;
171
171
  }
172
172
 
173
- const length = getMaxPathLength(el);
174
173
  css(el, 'strokeDasharray', length);
175
174
 
176
- if (unit === '%') {
177
- steps = steps.map((step) => (step * length) / 100);
178
- }
179
-
180
- steps = steps.reverse();
181
-
182
175
  return (css, percent) => {
183
- css.strokeDashoffset = getValue(steps, percent);
176
+ css.strokeDashoffset = getValue(stops, percent);
184
177
  };
185
178
  }
186
179
 
187
- function backgroundFn(prop, el, steps) {
188
- if (steps.length === 1) {
189
- steps.unshift(0);
180
+ function backgroundFn(prop, el, stops) {
181
+ if (stops.length === 1) {
182
+ stops.unshift(0);
190
183
  }
191
184
 
192
185
  prop = prop.substr(-1);
193
186
  const attr = prop === 'y' ? 'height' : 'width';
194
- steps = steps.map((step) => toPx(step, attr, el));
187
+ stops = parseStops(stops, (stop) => toPx(stop, attr, el));
195
188
 
196
189
  const bgPos = getCssValue(el, `background-position-${prop}`, '');
197
190
 
198
191
  return getCssValue(el, 'backgroundSize', '') === 'cover'
199
- ? backgroundCoverFn(prop, el, steps, bgPos, attr)
200
- : setBackgroundPosFn(prop, steps, bgPos);
192
+ ? backgroundCoverFn(prop, el, stops, bgPos, attr)
193
+ : setBackgroundPosFn(prop, stops, bgPos);
201
194
  }
202
195
 
203
- function backgroundCoverFn(prop, el, steps, bgPos, attr) {
196
+ function backgroundCoverFn(prop, el, stops, bgPos, attr) {
204
197
  const dimImage = getBackgroundImageDimensions(el);
205
198
 
206
199
  if (!dimImage.width) {
207
200
  return noop;
208
201
  }
209
202
 
210
- const min = Math.min(...steps);
211
- const max = Math.max(...steps);
212
- const down = steps.indexOf(min) < steps.indexOf(max);
203
+ const values = stops.map(([value]) => value);
204
+ const min = Math.min(...values);
205
+ const max = Math.max(...values);
206
+ const down = values.indexOf(min) < values.indexOf(max);
213
207
 
214
208
  const diff = max - min;
215
209
  let pos = (down ? -diff : 0) - (down ? min : max);
@@ -234,7 +228,7 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
234
228
 
235
229
  const dim = Dimensions.cover(dimImage, dimEl);
236
230
 
237
- const fn = setBackgroundPosFn(prop, steps, `${pos}px`);
231
+ const fn = setBackgroundPosFn(prop, stops, `${pos}px`);
238
232
  return (css, percent) => {
239
233
  fn(css, percent);
240
234
  css.backgroundSize = `${dim.width}px ${dim.height}px`;
@@ -242,9 +236,9 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
242
236
  };
243
237
  }
244
238
 
245
- function setBackgroundPosFn(prop, steps, pos) {
239
+ function setBackgroundPosFn(prop, stops, pos) {
246
240
  return function (css, percent) {
247
- css[`background-position-${prop}`] = `calc(${pos} + ${getValue(steps, percent)}px)`;
241
+ css[`background-position-${prop}`] = `calc(${pos} + ${getValue(stops, percent)}px)`;
248
242
  };
249
243
  }
250
244
 
@@ -278,27 +272,71 @@ function toDimensions(image) {
278
272
  };
279
273
  }
280
274
 
281
- function getStep(steps, percent) {
282
- const count = steps.length - 1;
283
- const index = Math.min(Math.floor(count * percent), count - 1);
275
+ function parseStops(stops, fn = toFloat) {
276
+ const result = [];
277
+ const { length } = stops;
278
+ let nullIndex = 0;
279
+ for (let i = 0; i < length; i++) {
280
+ let [value, percent] = isString(stops[i]) ? stops[i].trim().split(' ') : [stops[i]];
281
+ value = fn(value);
282
+ percent = percent ? toFloat(percent) / 100 : null;
283
+
284
+ if (i === 0) {
285
+ if (percent === null) {
286
+ percent = 0;
287
+ } else if (percent) {
288
+ result.push([value, 0]);
289
+ }
290
+ } else if (i === length - 1) {
291
+ if (percent === null) {
292
+ percent = 1;
293
+ } else if (percent !== 1) {
294
+ result.push([value, percent]);
295
+ percent = 1;
296
+ }
297
+ }
298
+
299
+ result.push([value, percent]);
300
+
301
+ if (percent === null) {
302
+ nullIndex++;
303
+ } else if (nullIndex) {
304
+ const leftPercent = result[i - nullIndex - 1][1];
305
+ const p = (percent - leftPercent) / (nullIndex + 1);
306
+ for (let j = nullIndex; j > 0; j--) {
307
+ result[i - j][1] = leftPercent + p * (nullIndex - j + 1);
308
+ }
309
+
310
+ nullIndex = 0;
311
+ }
312
+ }
313
+
314
+ return result;
315
+ }
284
316
 
285
- return steps
286
- .slice(index, index + 2)
287
- .concat(percent === 1 ? 1 : (percent % (1 / count)) * count);
317
+ function getStop(stops, percent) {
318
+ const index = findIndex(stops.slice(1), ([, targetPercent]) => percent <= targetPercent) + 1;
319
+ return [
320
+ stops[index - 1][0],
321
+ stops[index][0],
322
+ (percent - stops[index - 1][1]) / (stops[index][1] - stops[index - 1][1]),
323
+ ];
288
324
  }
289
325
 
290
- function getValue(steps, percent) {
291
- const [start, end, p] = getStep(steps, percent);
326
+ function getValue(stops, percent) {
327
+ const [start, end, p] = getStop(stops, percent);
292
328
  return isNumber(start) ? start + Math.abs(start - end) * p * (start < end ? 1 : -1) : +end;
293
329
  }
294
330
 
295
- function getUnit(steps, defaultUnit) {
296
- return (
297
- steps.reduce(
298
- (unit, step) => unit || (isString(step) && step.replace(/[\d-]/g, '').trim()),
299
- ''
300
- ) || defaultUnit
301
- );
331
+ const unitRe = /^-?\d+([^\s]*)/;
332
+ function getUnit(stops, defaultUnit) {
333
+ for (const stop of stops) {
334
+ const match = stop.match?.(unitRe);
335
+ if (match) {
336
+ return match[1];
337
+ }
338
+ }
339
+ return defaultUnit;
302
340
  }
303
341
 
304
342
  function getCssValue(el, prop, value) {
@@ -26,17 +26,17 @@ export default {
26
26
  },
27
27
 
28
28
  created() {
29
- ['start', 'move', 'end'].forEach((key) => {
29
+ for (const key of ['start', 'move', 'end']) {
30
30
  const fn = this[key];
31
31
  this[key] = (e) => {
32
32
  const pos = getEventPos(e).x * (isRtl ? -1 : 1);
33
33
 
34
- this.prevPos = pos !== this.pos ? this.pos : this.prevPos;
34
+ this.prevPos = pos === this.pos ? this.prevPos : this.pos;
35
35
  this.pos = pos;
36
36
 
37
37
  fn(e);
38
38
  };
39
- });
39
+ }
40
40
  },
41
41
 
42
42
  events: [
@@ -61,7 +61,7 @@ export default {
61
61
  methods: {
62
62
  updateNav() {
63
63
  const i = this.getValidIndex();
64
- this.navItems.forEach((el) => {
64
+ for (const el of this.navItems) {
65
65
  const cmd = data(el, this.attrItem);
66
66
 
67
67
  toggleClass(el, this.clsActive, toNumber(cmd) === i);
@@ -71,7 +71,7 @@ export default {
71
71
  this.finite &&
72
72
  ((cmd === 'previous' && i === 0) || (cmd === 'next' && i >= this.maxIndex))
73
73
  );
74
- });
74
+ }
75
75
  },
76
76
  },
77
77
  };
@@ -4,7 +4,6 @@ import SliderNav from './slider-nav';
4
4
  import {
5
5
  $,
6
6
  $$,
7
- assign,
8
7
  clamp,
9
8
  fastdom,
10
9
  getIndex,
@@ -170,21 +169,14 @@ export default {
170
169
  },
171
170
 
172
171
  _show(prev, next, force) {
173
- this._transitioner = this._getTransitioner(
174
- prev,
175
- next,
176
- this.dir,
177
- assign(
178
- {
179
- easing: force
180
- ? next.offsetWidth < 600
181
- ? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
182
- : 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
183
- : this.easing,
184
- },
185
- this.transitionOptions
186
- )
187
- );
172
+ this._transitioner = this._getTransitioner(prev, next, this.dir, {
173
+ easing: force
174
+ ? next.offsetWidth < 600
175
+ ? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
176
+ : 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
177
+ : this.easing,
178
+ ...this.transitionOptions,
179
+ });
188
180
 
189
181
  if (!force && !prev) {
190
182
  this._translate(1);
@@ -1,7 +1,7 @@
1
1
  import Animations from './internal/slideshow-animations';
2
2
  import Transitioner from './internal/slideshow-transitioner';
3
3
  import Slider from './slider.js';
4
- import { addClass, assign, removeClass } from 'uikit-util';
4
+ import { addClass, removeClass } from 'uikit-util';
5
5
 
6
6
  export default {
7
7
  mixins: [Slider],
@@ -19,7 +19,7 @@ export default {
19
19
 
20
20
  computed: {
21
21
  animation({ animation, Animations }) {
22
- return assign(Animations[animation] || Animations.slide, { name: animation });
22
+ return { ...(Animations[animation] || Animations.slide), name: animation };
23
23
  },
24
24
 
25
25
  transitionOptions() {
@@ -2,7 +2,6 @@ import {
2
2
  $$,
3
3
  addClass,
4
4
  Animation,
5
- assign,
6
5
  css,
7
6
  fastdom,
8
7
  hasClass,
@@ -175,7 +174,7 @@ export function toggleHeight({ isToggled, duration, initProps, hideProps, transi
175
174
  show
176
175
  ? Transition.start(
177
176
  el,
178
- assign({}, initProps, { overflow: 'hidden', height: endHeight }),
177
+ { ...initProps, overflow: 'hidden', height: endHeight },
179
178
  Math.round(duration * (1 - currentHeight / endHeight)),
180
179
  transition
181
180
  )
@@ -2,18 +2,15 @@ import { on } from './event';
2
2
  import { assign, noop } from './lang';
3
3
 
4
4
  export function ajax(url, options) {
5
- const env = assign(
6
- {
7
- data: null,
8
- method: 'GET',
9
- headers: {},
10
- xhr: new XMLHttpRequest(),
11
- beforeSend: noop,
12
- responseType: '',
13
- },
14
- options
15
- );
16
-
5
+ const env = {
6
+ data: null,
7
+ method: 'GET',
8
+ headers: {},
9
+ xhr: new XMLHttpRequest(),
10
+ beforeSend: noop,
11
+ responseType: '',
12
+ ...options,
13
+ };
17
14
  return Promise.resolve()
18
15
  .then(() => env.beforeSend(env))
19
16
  .then(() => send(url, env));
@@ -63,8 +60,12 @@ export function getImage(src, srcset, sizes) {
63
60
  return new Promise((resolve, reject) => {
64
61
  const img = new Image();
65
62
 
66
- img.onerror = (e) => reject(e);
67
- img.onload = () => resolve(img);
63
+ img.onerror = (e) => {
64
+ reject(e);
65
+ };
66
+ img.onload = () => {
67
+ resolve(img);
68
+ };
68
69
 
69
70
  sizes && (img.sizes = sizes);
70
71
  srcset && (img.srcset = srcset);
@@ -1,7 +1,7 @@
1
1
  import { attr } from './attr';
2
2
  import { once, trigger } from './event';
3
3
  import { css, propName } from './style';
4
- import { assign, startsWith, toNodes } from './lang';
4
+ import { startsWith, toNodes } from './lang';
5
5
  import { addClass, hasClass, removeClass, removeClasses } from './class';
6
6
 
7
7
  export function transition(element, props, duration = 400, timing = 'linear') {
@@ -35,17 +35,12 @@ export function transition(element, props, duration = 400, timing = 'linear') {
35
35
  );
36
36
 
37
37
  addClass(element, 'uk-transition');
38
- css(
39
- element,
40
- assign(
41
- {
42
- transitionProperty: Object.keys(props).map(propName).join(','),
43
- transitionDuration: `${duration}ms`,
44
- transitionTimingFunction: timing,
45
- },
46
- props
47
- )
48
- );
38
+ css(element, {
39
+ transitionProperty: Object.keys(props).map(propName).join(','),
40
+ transitionDuration: `${duration}ms`,
41
+ transitionTimingFunction: timing,
42
+ ...props,
43
+ });
49
44
  })
50
45
  )
51
46
  );
@@ -11,17 +11,17 @@ export function attr(element, name, value) {
11
11
  if (isUndefined(value)) {
12
12
  return toNode(element)?.getAttribute(name);
13
13
  } else {
14
- toNodes(element).forEach((element) => {
14
+ for (const el of toNodes(element)) {
15
15
  if (isFunction(value)) {
16
- value = value.call(element, attr(element, name));
16
+ value = value.call(el, attr(el, name));
17
17
  }
18
18
 
19
19
  if (value === null) {
20
- removeAttr(element, name);
20
+ removeAttr(el, name);
21
21
  } else {
22
- element.setAttribute(name, value);
22
+ el.setAttribute(name, value);
23
23
  }
24
- });
24
+ }
25
25
  }
26
26
  }
27
27
 
@@ -30,16 +30,18 @@ export function hasAttr(element, name) {
30
30
  }
31
31
 
32
32
  export function removeAttr(element, name) {
33
- element = toNodes(element);
34
- name.split(' ').forEach((name) =>
35
- element.forEach((element) => element.hasAttribute(name) && element.removeAttribute(name))
36
- );
33
+ const elements = toNodes(element);
34
+ for (const attribute of name.split(' ')) {
35
+ for (const element of elements) {
36
+ element.removeAttribute(attribute);
37
+ }
38
+ }
37
39
  }
38
40
 
39
41
  export function data(element, attribute) {
40
- for (let i = 0, attrs = [attribute, `data-${attribute}`]; i < attrs.length; i++) {
41
- if (hasAttr(element, attrs[i])) {
42
- return attr(element, attrs[i]);
42
+ for (const name of [attribute, `data-${attribute}`]) {
43
+ if (hasAttr(element, name)) {
44
+ return attr(element, name);
43
45
  }
44
46
  }
45
47
  }
@@ -37,8 +37,8 @@ export function offset(element, coordinates) {
37
37
  const currentOffset = dimensions(element);
38
38
 
39
39
  if (element) {
40
- const { pageYOffset, pageXOffset } = toWindow(element);
41
- const offsetBy = { height: pageYOffset, width: pageXOffset };
40
+ const { scrollY, scrollX } = toWindow(element);
41
+ const offsetBy = { height: scrollY, width: scrollX };
42
42
 
43
43
  for (const dir in dirs) {
44
44
  for (const i in dirs[dir]) {
@@ -104,8 +104,8 @@ export function offsetPosition(element) {
104
104
 
105
105
  if (css(element, 'position') === 'fixed') {
106
106
  const win = toWindow(element);
107
- offset[0] += win.pageYOffset;
108
- offset[1] += win.pageXOffset;
107
+ offset[0] += win.scrollY;
108
+ offset[1] += win.scrollX;
109
109
  return offset;
110
110
  }
111
111
  } while ((element = element.offsetParent));