uikit 3.25.24-dev.66bb413 → 3.25.24

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 (47) hide show
  1. package/dist/css/uikit-core-rtl.css +1 -1
  2. package/dist/css/uikit-core-rtl.min.css +1 -1
  3. package/dist/css/uikit-core.css +1 -1
  4. package/dist/css/uikit-core.min.css +1 -1
  5. package/dist/css/uikit-rtl.css +1 -1
  6. package/dist/css/uikit-rtl.min.css +1 -1
  7. package/dist/css/uikit.css +1 -1
  8. package/dist/css/uikit.min.css +1 -1
  9. package/dist/js/components/countdown.js +1 -1
  10. package/dist/js/components/countdown.min.js +1 -1
  11. package/dist/js/components/filter.js +18 -16
  12. package/dist/js/components/filter.min.js +1 -1
  13. package/dist/js/components/lightbox-panel.js +8 -27
  14. package/dist/js/components/lightbox-panel.min.js +1 -1
  15. package/dist/js/components/lightbox.js +8 -27
  16. package/dist/js/components/lightbox.min.js +1 -1
  17. package/dist/js/components/notification.js +1 -1
  18. package/dist/js/components/notification.min.js +1 -1
  19. package/dist/js/components/parallax.js +1 -1
  20. package/dist/js/components/parallax.min.js +1 -1
  21. package/dist/js/components/slider-parallax.js +1 -1
  22. package/dist/js/components/slider-parallax.min.js +1 -1
  23. package/dist/js/components/slider.js +15 -16
  24. package/dist/js/components/slider.min.js +1 -1
  25. package/dist/js/components/slideshow-parallax.js +1 -1
  26. package/dist/js/components/slideshow-parallax.min.js +1 -1
  27. package/dist/js/components/slideshow.js +1 -1
  28. package/dist/js/components/slideshow.min.js +1 -1
  29. package/dist/js/components/sortable.js +18 -16
  30. package/dist/js/components/sortable.min.js +1 -1
  31. package/dist/js/components/tooltip.js +4 -5
  32. package/dist/js/components/tooltip.min.js +1 -1
  33. package/dist/js/components/upload.js +1 -1
  34. package/dist/js/components/upload.min.js +1 -1
  35. package/dist/js/uikit-core.js +64 -75
  36. package/dist/js/uikit-core.min.js +1 -1
  37. package/dist/js/uikit-icons.js +1 -1
  38. package/dist/js/uikit-icons.min.js +1 -1
  39. package/dist/js/uikit.js +95 -105
  40. package/dist/js/uikit.min.js +1 -1
  41. package/package.json +1 -1
  42. package/src/js/components/internal/slider-transitioner.js +15 -17
  43. package/src/js/core/scrollspy.js +10 -20
  44. package/src/js/mixin/internal/animate-fade.js +20 -18
  45. package/src/js/mixin/modal.js +3 -24
  46. package/src/js/mixin/togglable.js +4 -4
  47. package/src/js/util/animation.js +58 -41
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.25.24-dev.66bb413",
5
+ "version": "3.25.24",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -73,25 +73,23 @@ export default function (prev, next, dir, { center, easing, list }) {
73
73
  },
74
74
 
75
75
  translate(percent) {
76
- if (percent === this.percent()) {
77
- return;
76
+ if (percent !== this.percent()) {
77
+ const distance = this.getDistance() * dir * (isRtl ? -1 : 1);
78
+
79
+ css(
80
+ list,
81
+ 'transform',
82
+ translate(
83
+ clamp(
84
+ -to + (distance - distance * percent),
85
+ -getWidth(list),
86
+ dimensions(list).width,
87
+ ) * (isRtl ? -1 : 1),
88
+ 'px',
89
+ ),
90
+ );
78
91
  }
79
92
 
80
- const distance = this.getDistance() * dir * (isRtl ? -1 : 1);
81
-
82
- css(
83
- list,
84
- 'transform',
85
- translate(
86
- clamp(
87
- -to + (distance - distance * percent),
88
- -getWidth(list),
89
- dimensions(list).width,
90
- ) * (isRtl ? -1 : 1),
91
- 'px',
92
- ),
93
- );
94
-
95
93
  const actives = this.getActives();
96
94
  const itemIn = this.getItemIn();
97
95
  const itemOut = this.getItemIn(true);
@@ -1,13 +1,4 @@
1
- import {
2
- $$,
3
- css,
4
- filter,
5
- data as getData,
6
- once,
7
- removeClass,
8
- toggleClass,
9
- trigger,
10
- } from 'uikit-util';
1
+ import { $$, css, filter, data as getData, removeClass, toggleClass, trigger } from 'uikit-util';
11
2
  import { intersection } from '../api/observables';
12
3
  import { awaitTimeout } from '../util/await';
13
4
 
@@ -121,16 +112,15 @@ export default {
121
112
  toggleClass(el, clsInView, inview);
122
113
  toggleClass(el, state.cls);
123
114
 
124
- let match;
125
- if ((match = state.cls.match(/\buk-animation-[\w-]+/g))) {
126
- const removeAnimationClasses = () => removeClass(el, match);
127
- if (inview) {
128
- state.off = once(el, 'animationcancel animationend', removeAnimationClasses, {
129
- self: true,
130
- });
131
- } else {
132
- removeAnimationClasses();
133
- }
115
+ const match = state.cls.match(/\buk-animation-[\w-]+/g);
116
+ if (match) {
117
+ const animations = (inview && el.getAnimations?.()) || [];
118
+
119
+ let active = true;
120
+ state.off = () => (active = false);
121
+
122
+ const cleanup = () => active && removeClass(el, match);
123
+ Promise.all(animations.map(({ finished }) => finished)).then(cleanup, cleanup);
134
124
  }
135
125
 
136
126
  trigger(el, inview ? 'inview' : 'outview');
@@ -69,29 +69,31 @@ export default function fade(action, target, duration, stagger = 0) {
69
69
  css(target, 'alignContent', 'flex-start');
70
70
  height(target, oldHeight);
71
71
 
72
- let transitions = [];
72
+ const transitions = [];
73
73
  let targetDuration = duration / 2;
74
74
  if (stagger) {
75
75
  const nodes = getTransitionNodes(target);
76
76
  css(children(target), propsOut);
77
77
 
78
- transitions = nodes.reduce(async (promise, child, i, array) => {
79
- await promise;
80
-
81
- if (!isInView(child) || !isCurrentIndex()) {
82
- resetProps(child, propsIn);
83
- return;
84
- }
85
-
86
- await awaitTimeout(stagger);
87
-
88
- const transition = Transition.start(child, propsIn, duration / 2, 'ease').then(
89
- () => isCurrentIndex() && resetProps(child, propsIn),
90
- );
91
- if (array.length - 1 === i) {
92
- await transition;
93
- }
94
- }, Promise.resolve());
78
+ transitions.push(
79
+ nodes.reduce(async (promise, child, i, array) => {
80
+ await promise;
81
+
82
+ if (!isInView(child) || !isCurrentIndex()) {
83
+ resetProps(child, propsIn);
84
+ return;
85
+ }
86
+
87
+ await awaitTimeout(stagger);
88
+
89
+ const transition = Transition.start(child, propsIn, duration / 2, 'ease').then(
90
+ () => isCurrentIndex() && resetProps(child, propsIn),
91
+ );
92
+ if (array.length - 1 === i) {
93
+ await transition;
94
+ }
95
+ }, Promise.resolve()),
96
+ );
95
97
 
96
98
  targetDuration += nodes.length * stagger;
97
99
  }
@@ -4,7 +4,6 @@ import {
4
4
  append,
5
5
  css,
6
6
  dimensions,
7
- endsWith,
8
7
  includes,
9
8
  isFocusable,
10
9
  isSameSiteAnchor,
@@ -239,25 +238,9 @@ function animate(el, show, { transitionElement, _toggle }) {
239
238
 
240
239
  _toggle(el, show);
241
240
 
242
- const off = once(
243
- transitionElement,
244
- 'transitionstart',
245
- () => {
246
- once(transitionElement, 'transitionend transitioncancel', resolve, {
247
- self: true,
248
- });
249
- clearTimeout(timer);
250
- },
251
- { self: true },
252
- );
253
-
254
- const timer = setTimeout(
255
- () => {
256
- off();
257
- resolve();
258
- },
259
- toMs(css(transitionElement, 'transitionDuration')),
260
- );
241
+ Promise.all(
242
+ (transitionElement.getAnimations?.() ?? []).map(({ finished }) => finished),
243
+ ).then(resolve, reject);
261
244
  }),
262
245
  ).then(() => {
263
246
  if (pendingReject.get(el) === rejectAnimation) {
@@ -266,10 +249,6 @@ function animate(el, show, { transitionElement, _toggle }) {
266
249
  });
267
250
  }
268
251
 
269
- function toMs(time) {
270
- return toFloat(time) * (endsWith(time, 'ms') ? 1 : 1000);
271
- }
272
-
273
252
  function preventBackgroundFocus(modal) {
274
253
  return on(document, 'focusin', (e) => {
275
254
  if (last(active) !== modal || modal.$el.contains(e.target)) {
@@ -242,7 +242,8 @@ async function toggleTransition(el, show, { animation, duration, velocity, trans
242
242
  }
243
243
  }
244
244
 
245
- function toggleAnimation(el, show, cmp) {
245
+ async function toggleAnimation(el, show, cmp) {
246
+ // Do not destructure origin: Tooltip sets it in _toggle's synchronous toggled handler.
246
247
  const { animation, duration, _toggle } = cmp;
247
248
 
248
249
  if (show) {
@@ -250,7 +251,6 @@ function toggleAnimation(el, show, cmp) {
250
251
  return Animation.in(el, animation[0], duration, cmp.origin);
251
252
  }
252
253
 
253
- return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(() =>
254
- _toggle(el, false),
255
- );
254
+ await Animation.out(el, animation[1] || animation[0], duration, cmp.origin);
255
+ _toggle(el, false);
256
256
  }
@@ -62,47 +62,66 @@ export const Transition = {
62
62
  };
63
63
 
64
64
  const clsAnimation = 'uk-animation';
65
- const animationEnd = 'animationend';
66
- const animationCanceled = 'animationcanceled';
65
+ const activeAnimations = new WeakMap();
67
66
 
68
67
  function animate(element, animation, duration = 200, origin, out) {
69
- return Promise.all(
70
- toNodes(element).map(
71
- (element) =>
72
- new Promise((resolve, reject) => {
73
- if (hasClass(element, clsAnimation)) {
74
- trigger(element, animationCanceled);
75
- }
76
-
77
- const classes = [
78
- animation,
79
- clsAnimation,
80
- `${clsAnimation}-${out ? 'leave' : 'enter'}`,
81
- origin && `uk-transform-origin-${origin}`,
82
- out && `${clsAnimation}-reverse`,
83
- ];
84
-
85
- const timer = setTimeout(() => trigger(element, animationEnd), duration);
86
-
87
- once(
88
- element,
89
- [animationEnd, animationCanceled],
90
- ({ type }) => {
91
- clearTimeout(timer);
92
-
93
- type === animationCanceled ? reject() : resolve(element);
68
+ const animateFn = async (element) => {
69
+ if (!Element.prototype.getAnimations) {
70
+ return element;
71
+ }
72
+
73
+ cancel(element);
74
+
75
+ const existingAnimations = element.getAnimations();
76
+
77
+ const classes = [
78
+ animation,
79
+ clsAnimation,
80
+ `${clsAnimation}-${out ? 'leave' : 'enter'}`,
81
+ origin && `uk-transform-origin-${origin}`,
82
+ out && `${clsAnimation}-reverse`,
83
+ ];
84
+
85
+ css(element, 'animationDuration', `${duration}ms`);
86
+ addClass(element, classes);
87
+
88
+ const animations = element
89
+ .getAnimations()
90
+ .filter((animation) => !existingAnimations.includes(animation));
91
+ const data = { animations, classes };
92
+
93
+ activeAnimations.set(element, data);
94
+
95
+ try {
96
+ await Promise.all(animations.map(({ finished }) => finished));
97
+ return element;
98
+ } finally {
99
+ cleanup(element, data);
100
+ }
101
+ };
102
+
103
+ return Promise.all(toNodes(element).map(animateFn));
104
+ }
94
105
 
95
- css(element, 'animationDuration', '');
96
- removeClass(element, classes);
97
- },
98
- { self: true },
99
- );
106
+ function cleanup(element, data) {
107
+ if (activeAnimations.get(element) === data) {
108
+ activeAnimations.delete(element);
109
+ css(element, 'animationDuration', '');
110
+ removeClass(element, data.classes);
111
+ }
112
+ }
100
113
 
101
- css(element, 'animationDuration', `${duration}ms`);
102
- addClass(element, classes);
103
- }),
104
- ),
105
- );
114
+ function cancel(elements) {
115
+ for (const element of toNodes(elements)) {
116
+ const data = activeAnimations.get(element);
117
+
118
+ if (data) {
119
+ for (const animation of data.animations) {
120
+ animation.cancel();
121
+ }
122
+ cleanup(element, data);
123
+ }
124
+ }
106
125
  }
107
126
 
108
127
  export const Animation = {
@@ -113,10 +132,8 @@ export const Animation = {
113
132
  },
114
133
 
115
134
  inProgress(element) {
116
- return hasClass(element, clsAnimation);
135
+ return activeAnimations.has(element);
117
136
  },
118
137
 
119
- cancel(element) {
120
- trigger(element, animationCanceled);
121
- },
138
+ cancel,
122
139
  };