uikit 3.25.24-dev.66bb413 → 3.25.24-dev.683b9f8

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 (45) 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 +1 -1
  12. package/dist/js/components/filter.min.js +1 -1
  13. package/dist/js/components/lightbox-panel.js +10 -29
  14. package/dist/js/components/lightbox-panel.min.js +1 -1
  15. package/dist/js/components/lightbox.js +10 -29
  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 +1 -1
  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 +1 -1
  30. package/dist/js/components/sortable.min.js +1 -1
  31. package/dist/js/components/tooltip.js +6 -7
  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 +66 -77
  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 +66 -77
  40. package/dist/js/uikit.min.js +1 -1
  41. package/package.json +1 -1
  42. package/src/js/core/scrollspy.js +10 -20
  43. package/src/js/mixin/modal.js +3 -24
  44. package/src/js/mixin/togglable.js +5 -6
  45. 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-dev.683b9f8",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -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');
@@ -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,15 +242,14 @@ async function toggleTransition(el, show, { animation, duration, velocity, trans
242
242
  }
243
243
  }
244
244
 
245
- function toggleAnimation(el, show, cmp) {
246
- const { animation, duration, _toggle } = cmp;
245
+ async function toggleAnimation(el, show, cmp) {
246
+ const { animation, duration, origin, _toggle } = cmp;
247
247
 
248
248
  if (show) {
249
249
  _toggle(el, true);
250
- return Animation.in(el, animation[0], duration, cmp.origin);
250
+ return Animation.in(el, animation[0], duration, origin);
251
251
  }
252
252
 
253
- return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(() =>
254
- _toggle(el, false),
255
- );
253
+ await Animation.out(el, animation[1] || animation[0], duration, origin);
254
+ _toggle(el, false);
256
255
  }
@@ -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
  };