uikit 3.11.2-dev.f2970ffaa → 3.12.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 (226) hide show
  1. package/.eslintrc.json +4 -49
  2. package/.prettierignore +14 -0
  3. package/.prettierrc.json +13 -0
  4. package/.webstorm.js +3 -3
  5. package/CHANGELOG.md +55 -19
  6. package/build/.eslintrc.json +1 -3
  7. package/build/build.js +26 -28
  8. package/build/icons.js +7 -11
  9. package/build/less.js +48 -36
  10. package/build/package.json +2 -2
  11. package/build/prefix.js +21 -18
  12. package/build/publishDev.js +6 -8
  13. package/build/release.js +20 -17
  14. package/build/scope.js +21 -11
  15. package/build/scss.js +72 -39
  16. package/build/util.js +71 -62
  17. package/build/wrapper/icons.js +0 -2
  18. package/dist/css/uikit-core-rtl.css +133 -201
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +133 -201
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +135 -207
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +135 -207
  25. package/dist/css/uikit.min.css +1 -1
  26. package/dist/js/components/countdown.js +66 -138
  27. package/dist/js/components/countdown.min.js +1 -1
  28. package/dist/js/components/filter.js +408 -439
  29. package/dist/js/components/filter.min.js +1 -1
  30. package/dist/js/components/lightbox-panel.js +1091 -1319
  31. package/dist/js/components/lightbox-panel.min.js +1 -1
  32. package/dist/js/components/lightbox.js +1137 -1396
  33. package/dist/js/components/lightbox.min.js +1 -1
  34. package/dist/js/components/notification.js +94 -114
  35. package/dist/js/components/notification.min.js +1 -1
  36. package/dist/js/components/parallax.js +347 -372
  37. package/dist/js/components/parallax.min.js +1 -1
  38. package/dist/js/components/slider-parallax.js +345 -360
  39. package/dist/js/components/slider-parallax.min.js +1 -1
  40. package/dist/js/components/slider.js +749 -843
  41. package/dist/js/components/slider.min.js +1 -1
  42. package/dist/js/components/slideshow-parallax.js +345 -360
  43. package/dist/js/components/slideshow-parallax.min.js +1 -1
  44. package/dist/js/components/slideshow.js +628 -798
  45. package/dist/js/components/slideshow.min.js +1 -1
  46. package/dist/js/components/sortable.js +587 -620
  47. package/dist/js/components/sortable.min.js +1 -1
  48. package/dist/js/components/tooltip.js +324 -356
  49. package/dist/js/components/tooltip.min.js +1 -1
  50. package/dist/js/components/upload.js +156 -167
  51. package/dist/js/components/upload.min.js +1 -1
  52. package/dist/js/uikit-core.js +5324 -6527
  53. package/dist/js/uikit-core.min.js +1 -1
  54. package/dist/js/uikit-icons.js +7 -9
  55. package/dist/js/uikit-icons.min.js +1 -1
  56. package/dist/js/uikit.js +8006 -9663
  57. package/dist/js/uikit.min.js +1 -1
  58. package/jsconfig.json +1 -1
  59. package/package.json +64 -60
  60. package/src/js/api/boot.js +25 -32
  61. package/src/js/api/component.js +15 -28
  62. package/src/js/api/global.js +6 -12
  63. package/src/js/api/hooks.js +14 -33
  64. package/src/js/api/instance.js +7 -15
  65. package/src/js/api/state.js +199 -187
  66. package/src/js/components/countdown.js +32 -85
  67. package/src/js/components/filter.js +70 -66
  68. package/src/js/components/index.js +13 -13
  69. package/src/js/components/internal/lightbox-animations.js +14 -25
  70. package/src/js/components/internal/slider-preload.js +9 -0
  71. package/src/js/components/internal/slider-transitioner.js +66 -45
  72. package/src/js/components/internal/slideshow-animations.js +46 -64
  73. package/src/js/components/lightbox-panel.js +107 -105
  74. package/src/js/components/lightbox.js +17 -39
  75. package/src/js/components/notification.js +49 -43
  76. package/src/js/components/parallax.js +21 -46
  77. package/src/js/components/slider-parallax.js +13 -23
  78. package/src/js/components/slider.js +117 -89
  79. package/src/js/components/slideshow-parallax.js +1 -1
  80. package/src/js/components/slideshow.js +15 -13
  81. package/src/js/components/sortable.js +125 -106
  82. package/src/js/components/tooltip.js +41 -31
  83. package/src/js/components/upload.js +53 -63
  84. package/src/js/core/accordion.js +58 -48
  85. package/src/js/core/alert.js +9 -17
  86. package/src/js/core/core.js +17 -69
  87. package/src/js/core/cover.js +15 -15
  88. package/src/js/core/drop.js +110 -94
  89. package/src/js/core/form-custom.js +22 -27
  90. package/src/js/core/gif.js +3 -7
  91. package/src/js/core/grid.js +57 -58
  92. package/src/js/core/height-match.js +16 -29
  93. package/src/js/core/height-viewport.js +30 -34
  94. package/src/js/core/icon.js +47 -52
  95. package/src/js/core/img.js +153 -143
  96. package/src/js/core/index.js +39 -39
  97. package/src/js/core/leader.js +9 -18
  98. package/src/js/core/margin.js +21 -37
  99. package/src/js/core/modal.js +49 -36
  100. package/src/js/core/nav.js +2 -4
  101. package/src/js/core/navbar.js +113 -85
  102. package/src/js/core/offcanvas.js +51 -54
  103. package/src/js/core/overflow-auto.js +13 -17
  104. package/src/js/core/responsive.js +14 -12
  105. package/src/js/core/scroll.js +10 -20
  106. package/src/js/core/scrollspy-nav.js +34 -31
  107. package/src/js/core/scrollspy.js +37 -54
  108. package/src/js/core/sticky.js +175 -123
  109. package/src/js/core/svg.js +68 -83
  110. package/src/js/core/switcher.js +56 -47
  111. package/src/js/core/tab.js +7 -10
  112. package/src/js/core/toggle.js +69 -68
  113. package/src/js/core/video.js +22 -21
  114. package/src/js/mixin/animate.js +19 -20
  115. package/src/js/mixin/class.js +2 -4
  116. package/src/js/mixin/container.js +7 -11
  117. package/src/js/mixin/internal/animate-fade.js +73 -30
  118. package/src/js/mixin/internal/animate-slide.js +58 -41
  119. package/src/js/mixin/internal/slideshow-animations.js +7 -14
  120. package/src/js/mixin/internal/slideshow-transitioner.js +10 -17
  121. package/src/js/mixin/lazyload.js +20 -0
  122. package/src/js/mixin/media.js +5 -10
  123. package/src/js/mixin/modal.js +89 -66
  124. package/src/js/mixin/parallax.js +149 -107
  125. package/src/js/mixin/position.js +26 -20
  126. package/src/js/mixin/slider-autoplay.js +12 -21
  127. package/src/js/mixin/slider-drag.js +64 -65
  128. package/src/js/mixin/slider-nav.js +26 -35
  129. package/src/js/mixin/slider-reactive.js +2 -8
  130. package/src/js/mixin/slider.js +47 -60
  131. package/src/js/mixin/slideshow.js +12 -22
  132. package/src/js/mixin/swipe.js +72 -0
  133. package/src/js/mixin/togglable.js +89 -63
  134. package/src/js/uikit-core.js +2 -4
  135. package/src/js/uikit.js +2 -4
  136. package/src/js/util/ajax.js +25 -40
  137. package/src/js/util/animation.js +77 -75
  138. package/src/js/util/attr.js +17 -21
  139. package/src/js/util/class.js +14 -52
  140. package/src/js/util/dimensions.js +78 -49
  141. package/src/js/util/dom.js +37 -66
  142. package/src/js/util/env.js +7 -12
  143. package/src/js/util/event.js +60 -59
  144. package/src/js/util/fastdom.js +1 -6
  145. package/src/js/util/filter.js +18 -36
  146. package/src/js/util/index.js +1 -1
  147. package/src/js/util/lang.js +82 -121
  148. package/src/js/util/mouse.js +19 -17
  149. package/src/js/util/observer.js +36 -0
  150. package/src/js/util/options.js +35 -49
  151. package/src/js/util/player.js +41 -36
  152. package/src/js/util/position.js +54 -46
  153. package/src/js/util/selector.js +43 -58
  154. package/src/js/util/style.js +39 -49
  155. package/src/js/util/viewport.js +75 -64
  156. package/src/less/components/base.less +10 -33
  157. package/src/less/components/flex.less +0 -9
  158. package/src/less/components/form-range.less +48 -95
  159. package/src/less/components/form.less +0 -1
  160. package/src/less/components/height.less +3 -0
  161. package/src/less/components/leader.less +0 -1
  162. package/src/less/components/lightbox.less +0 -1
  163. package/src/less/components/modal.less +3 -7
  164. package/src/less/components/navbar.less +0 -7
  165. package/src/less/components/progress.less +14 -36
  166. package/src/less/components/slider.less +0 -3
  167. package/src/less/components/slideshow.less +0 -3
  168. package/src/less/components/text.less +16 -32
  169. package/src/less/components/utility.less +25 -0
  170. package/src/scss/components/base.scss +10 -33
  171. package/src/scss/components/flex.scss +0 -9
  172. package/src/scss/components/form-range.scss +48 -95
  173. package/src/scss/components/form.scss +3 -4
  174. package/src/scss/components/height.scss +3 -0
  175. package/src/scss/components/icon.scss +2 -2
  176. package/src/scss/components/leader.scss +0 -1
  177. package/src/scss/components/lightbox.scss +0 -1
  178. package/src/scss/components/modal.scss +3 -7
  179. package/src/scss/components/navbar.scss +0 -7
  180. package/src/scss/components/progress.scss +14 -36
  181. package/src/scss/components/search.scss +1 -1
  182. package/src/scss/components/slider.scss +0 -3
  183. package/src/scss/components/slideshow.scss +0 -3
  184. package/src/scss/components/text.scss +16 -32
  185. package/src/scss/components/utility.scss +25 -0
  186. package/src/scss/mixins-theme.scss +1 -1
  187. package/src/scss/mixins.scss +1 -1
  188. package/src/scss/variables-theme.scss +9 -9
  189. package/src/scss/variables.scss +9 -9
  190. package/tests/align.html +10 -10
  191. package/tests/animation.html +2 -2
  192. package/tests/article.html +2 -2
  193. package/tests/base.html +3 -3
  194. package/tests/card.html +10 -10
  195. package/tests/column.html +3 -3
  196. package/tests/comment.html +9 -9
  197. package/tests/countdown.html +10 -8
  198. package/tests/dotnav.html +3 -3
  199. package/tests/image.html +296 -64
  200. package/tests/images/image-type.avif +0 -0
  201. package/tests/images/image-type.jpeg +0 -0
  202. package/tests/images/image-type.webp +0 -0
  203. package/tests/index.html +8 -8
  204. package/tests/js/index.js +114 -85
  205. package/tests/lightbox.html +10 -10
  206. package/tests/marker.html +2 -2
  207. package/tests/modal.html +8 -9
  208. package/tests/navbar.html +2 -2
  209. package/tests/overlay.html +7 -7
  210. package/tests/parallax.html +16 -7
  211. package/tests/position.html +12 -12
  212. package/tests/slidenav.html +12 -12
  213. package/tests/slider.html +20 -20
  214. package/tests/sortable.html +1 -1
  215. package/tests/sticky-parallax.html +87 -99
  216. package/tests/sticky.html +56 -24
  217. package/tests/svg.html +6 -6
  218. package/tests/table.html +11 -11
  219. package/tests/thumbnav.html +12 -12
  220. package/tests/transition.html +30 -30
  221. package/tests/utility.html +50 -33
  222. package/tests/video.html +1 -1
  223. package/tests/width.html +1 -1
  224. package/src/js/mixin/flex-bug.js +0 -56
  225. package/src/js/util/promise.js +0 -191
  226. package/tests/images/animated.gif +0 -0
@@ -1,6 +1,19 @@
1
1
  import Media from '../mixin/media';
2
- import {getMaxPathLength} from '../core/svg';
3
- import {css, Dimensions, each, isNumber, isString, isUndefined, noop, startsWith, toFloat, toPx, trigger, ucfirst} from 'uikit-util';
2
+ import { getMaxPathLength } from '../core/svg';
3
+ import {
4
+ css,
5
+ Dimensions,
6
+ each,
7
+ findIndex,
8
+ isNumber,
9
+ isString,
10
+ isUndefined,
11
+ noop,
12
+ toFloat,
13
+ toPx,
14
+ trigger,
15
+ ucfirst,
16
+ } from 'uikit-util';
4
17
 
5
18
  const props = {
6
19
  x: transformFn,
@@ -20,13 +33,12 @@ const props = {
20
33
  opacity: cssPropFn,
21
34
  stroke: strokeFn,
22
35
  bgx: backgroundFn,
23
- bgy: backgroundFn
36
+ bgy: backgroundFn,
24
37
  };
25
38
 
26
- const {keys} = Object;
39
+ const { keys } = Object;
27
40
 
28
41
  export default {
29
-
30
42
  mixins: [Media],
31
43
 
32
44
  props: fillObject(keys(props), 'list'),
@@ -34,7 +46,6 @@ export default {
34
46
  data: fillObject(keys(props), undefined),
35
47
 
36
48
  computed: {
37
-
38
49
  props(properties, $el) {
39
50
  return keys(props).reduce((result, prop) => {
40
51
  if (!isUndefined(properties[prop])) {
@@ -42,73 +53,65 @@ export default {
42
53
  }
43
54
  return result;
44
55
  }, {});
45
- }
46
-
56
+ },
47
57
  },
48
58
 
49
59
  events: {
50
- bgimageload() {
60
+ load() {
51
61
  this.$emit();
52
- }
62
+ },
53
63
  },
54
64
 
55
65
  methods: {
56
-
57
66
  reset() {
58
67
  each(this.getCss(0), (_, prop) => css(this.$el, prop, ''));
59
68
  },
60
69
 
61
70
  getCss(percent) {
62
- return keys(this.props).reduce((css, prop) => {
71
+ const css = { transform: '', filter: '' };
72
+ for (const prop in this.props) {
63
73
  this.props[prop](css, percent);
64
- return css;
65
- }, {transform: '', filter: ''});
66
- }
67
-
68
- }
69
-
74
+ }
75
+ return css;
76
+ },
77
+ },
70
78
  };
71
79
 
72
- function transformFn(prop, el, steps) {
73
-
74
- const unit = getUnit(steps) || {x: 'px', y: 'px', rotate: 'deg'}[prop] || '';
80
+ function transformFn(prop, el, stops) {
81
+ const unit = getUnit(stops) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
82
+ let transformFn;
75
83
 
76
84
  if (prop === 'x' || prop === 'y') {
77
85
  prop = `translate${ucfirst(prop)}`;
86
+ transformFn = (stop) => toFloat(toFloat(stop).toFixed(unit === 'px' ? 0 : 6));
78
87
  }
79
88
 
80
- steps = steps.map(toFloat);
81
-
82
- if (steps.length === 1) {
83
- steps.unshift(prop === 'scale' ? 1 : 0);
89
+ if (stops.length === 1) {
90
+ stops.unshift(prop === 'scale' ? 1 : 0);
84
91
  }
85
92
 
86
- return (css, percent) => {
87
- let value = getValue(steps, percent);
93
+ stops = parseStops(stops, transformFn);
88
94
 
89
- if (startsWith(prop, 'translate')) {
90
- value = toFloat(value).toFixed(unit === 'px' ? 0 : 6);
91
- }
92
-
93
- css.transform += ` ${prop}(${value}${unit})`;
95
+ return (css, percent) => {
96
+ css.transform += ` ${prop}(${getValue(stops, percent)}${unit})`;
94
97
  };
95
98
  }
96
99
 
97
- function colorFn(prop, el, steps) {
98
-
99
- if (steps.length === 1) {
100
- steps.unshift(getCssValue(el, prop, ''));
100
+ function colorFn(prop, el, stops) {
101
+ if (stops.length === 1) {
102
+ stops.unshift(getCssValue(el, prop, ''));
101
103
  }
102
104
 
103
- steps = steps.map(step => parseColor(el, step));
105
+ stops = parseStops(stops, (stop) => parseColor(el, stop));
104
106
 
105
107
  return (css, percent) => {
106
-
107
- const [start, end, p] = getStep(steps, percent);
108
- const value = start.map((value, i) => {
109
- value += p * (end[i] - value);
110
- return i === 3 ? toFloat(value) : parseInt(value, 10);
111
- }).join(',');
108
+ const [start, end, p] = getStop(stops, percent);
109
+ const value = start
110
+ .map((value, i) => {
111
+ value += p * (end[i] - value);
112
+ return i === 3 ? toFloat(value) : parseInt(value, 10);
113
+ })
114
+ .join(',');
112
115
  css[prop] = `rgba(${value})`;
113
116
  };
114
117
  }
@@ -122,98 +125,90 @@ function parseColor(el, color) {
122
125
  .map(toFloat);
123
126
  }
124
127
 
125
- function filterFn(prop, el, steps) {
126
-
127
- if (steps.length === 1) {
128
- steps.unshift(0);
128
+ function filterFn(prop, el, stops) {
129
+ if (stops.length === 1) {
130
+ stops.unshift(0);
129
131
  }
130
132
 
131
- const unit = getUnit(steps) || {blur: 'px', hue: 'deg'}[prop] || '%';
132
- prop = {fopacity: 'opacity', hue: 'hue-rotate'}[prop] || prop;
133
- steps = steps.map(toFloat);
133
+ const unit = getUnit(stops) || { blur: 'px', hue: 'deg' }[prop] || '%';
134
+ prop = { fopacity: 'opacity', hue: 'hue-rotate' }[prop] || prop;
135
+ stops = parseStops(stops);
134
136
 
135
137
  return (css, percent) => {
136
- const value = getValue(steps, percent);
138
+ const value = getValue(stops, percent);
137
139
  css.filter += ` ${prop}(${value + unit})`;
138
140
  };
139
141
  }
140
142
 
141
- function cssPropFn(prop, el, steps) {
142
-
143
- if (steps.length === 1) {
144
- steps.unshift(getCssValue(el, prop, ''));
143
+ function cssPropFn(prop, el, stops) {
144
+ if (stops.length === 1) {
145
+ stops.unshift(getCssValue(el, prop, ''));
145
146
  }
146
147
 
147
- steps = steps.map(toFloat);
148
+ stops = parseStops(stops);
148
149
 
149
150
  return (css, percent) => {
150
- css[prop] = getValue(steps, percent);
151
+ css[prop] = getValue(stops, percent);
151
152
  };
152
153
  }
153
154
 
154
- function strokeFn(prop, el, steps) {
155
-
156
- if (steps.length === 1) {
157
- steps.unshift(0);
155
+ function strokeFn(prop, el, stops) {
156
+ if (stops.length === 1) {
157
+ stops.unshift(0);
158
158
  }
159
159
 
160
- const unit = getUnit(steps);
161
- steps = steps.map(toFloat);
160
+ const unit = getUnit(stops);
161
+ const length = getMaxPathLength(el);
162
+ stops = parseStops(stops.reverse(), (stop) => {
163
+ stop = toFloat(stop);
164
+ return unit === '%' ? (stop * length) / 100 : stop;
165
+ });
162
166
 
163
- if (!steps.some(step => step)) {
167
+ if (!stops.some(([value]) => value)) {
164
168
  return noop;
165
169
  }
166
170
 
167
- const length = getMaxPathLength(el);
168
171
  css(el, 'strokeDasharray', length);
169
172
 
170
- if (unit === '%') {
171
- steps = steps.map(step => step * length / 100);
172
- }
173
-
174
- steps = steps.reverse();
175
-
176
173
  return (css, percent) => {
177
- css.strokeDashoffset = getValue(steps, percent);
174
+ css.strokeDashoffset = getValue(stops, percent);
178
175
  };
179
176
  }
180
177
 
181
- function backgroundFn(prop, el, steps) {
182
-
183
- if (steps.length === 1) {
184
- steps.unshift(0);
178
+ function backgroundFn(prop, el, stops) {
179
+ if (stops.length === 1) {
180
+ stops.unshift(0);
185
181
  }
186
182
 
187
183
  prop = prop.substr(-1);
188
184
  const attr = prop === 'y' ? 'height' : 'width';
189
- steps = steps.map(step => toPx(step, attr, el));
185
+ stops = parseStops(stops, (stop) => toPx(stop, attr, el));
190
186
 
191
- css(el, `background-position-${prop}`, '');
192
- const bgPos = css(el, 'backgroundPosition').split(' ')[prop === 'x' ? 0 : 1]; // IE 11 can't read background-position-[x|y]
187
+ const bgPos = getCssValue(el, `background-position-${prop}`, '');
193
188
 
194
189
  return getCssValue(el, 'backgroundSize', '') === 'cover'
195
- ? backgroundCoverFn(prop, el, steps, bgPos, attr)
196
- : setBackgroundPosFn(prop, steps, bgPos);
190
+ ? backgroundCoverFn(prop, el, stops, bgPos, attr)
191
+ : setBackgroundPosFn(prop, stops, bgPos);
197
192
  }
198
193
 
199
- function backgroundCoverFn(prop, el, steps, bgPos, attr) {
200
-
194
+ function backgroundCoverFn(prop, el, stops, bgPos, attr) {
201
195
  const dimImage = getBackgroundImageDimensions(el);
202
196
 
203
197
  if (!dimImage.width) {
204
198
  return noop;
205
199
  }
206
200
 
207
- const min = Math.min(...steps);
208
- const max = Math.max(...steps);
209
- const down = steps.indexOf(min) < steps.indexOf(max);
201
+ const values = stops.map(([value]) => value);
202
+ const min = Math.min(...values);
203
+ const max = Math.max(...values);
204
+ const down = values.indexOf(min) < values.indexOf(max);
210
205
 
211
206
  const diff = max - min;
212
207
  let pos = (down ? -diff : 0) - (down ? min : max);
213
208
 
214
209
  const dimEl = {
215
210
  width: el.offsetWidth,
216
- height: el.offsetHeight
211
+ height: el.offsetHeight,
217
212
  };
218
213
 
219
214
  const baseDim = Dimensions.cover(dimImage, dimEl);
@@ -222,7 +217,6 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
222
217
  if (span < diff) {
223
218
  dimEl[attr] = baseDim[attr] + diff - span;
224
219
  } else if (span > diff) {
225
-
226
220
  const posPercentage = dimEl[attr] / toPx(bgPos, attr, el, true);
227
221
 
228
222
  if (posPercentage) {
@@ -232,7 +226,7 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
232
226
 
233
227
  const dim = Dimensions.cover(dimImage, dimEl);
234
228
 
235
- const fn = setBackgroundPosFn(prop, steps, `${pos}px`);
229
+ const fn = setBackgroundPosFn(prop, stops, `${pos}px`);
236
230
  return (css, percent) => {
237
231
  fn(css, percent);
238
232
  css.backgroundSize = `${dim.width}px ${dim.height}px`;
@@ -240,9 +234,9 @@ function backgroundCoverFn(prop, el, steps, bgPos, attr) {
240
234
  };
241
235
  }
242
236
 
243
- function setBackgroundPosFn(prop, steps, pos) {
237
+ function setBackgroundPosFn(prop, stops, pos) {
244
238
  return function (css, percent) {
245
- css[`background-position-${prop}`] = `calc(${pos} + ${getValue(steps, percent)}px)`;
239
+ css[`background-position-${prop}`] = `calc(${pos} + ${getValue(stops, percent)}px)`;
246
240
  };
247
241
  }
248
242
 
@@ -261,39 +255,87 @@ function getBackgroundImageDimensions(el) {
261
255
  if (!image.naturalWidth) {
262
256
  image.onload = () => {
263
257
  dimensions[src] = toDimensions(image);
264
- trigger(el, 'bgimageload');
258
+ trigger(el, 'load');
265
259
  };
260
+ return toDimensions(image);
266
261
  }
267
262
  }
268
263
 
269
- return dimensions[src] = toDimensions(image);
264
+ return (dimensions[src] = toDimensions(image));
270
265
  }
271
266
 
272
267
  function toDimensions(image) {
273
268
  return {
274
269
  width: image.naturalWidth,
275
- height: image.naturalHeight
270
+ height: image.naturalHeight,
276
271
  };
277
272
  }
278
273
 
279
- function getStep(steps, percent) {
280
- const count = steps.length - 1;
281
- const index = Math.min(Math.floor(count * percent), count - 1);
274
+ function parseStops(stops, fn = toFloat) {
275
+ const result = [];
276
+ const { length } = stops;
277
+ let nullIndex = 0;
278
+ for (let i = 0; i < length; i++) {
279
+ let [value, percent] = isString(stops[i]) ? stops[i].trim().split(' ') : [stops[i]];
280
+ value = fn(value);
281
+ percent = percent ? toFloat(percent) / 100 : null;
282
+
283
+ if (i === 0) {
284
+ if (percent === null) {
285
+ percent = 0;
286
+ } else if (percent) {
287
+ result.push([value, 0]);
288
+ }
289
+ } else if (i === length - 1) {
290
+ if (percent === null) {
291
+ percent = 1;
292
+ } else if (percent !== 1) {
293
+ result.push([value, percent]);
294
+ percent = 1;
295
+ }
296
+ }
297
+
298
+ result.push([value, percent]);
299
+
300
+ if (percent === null) {
301
+ nullIndex++;
302
+ } else if (nullIndex) {
303
+ const leftPercent = result[i - nullIndex - 1][1];
304
+ const p = (percent - leftPercent) / (nullIndex + 1);
305
+ for (let j = nullIndex; j > 0; j--) {
306
+ result[i - j][1] = leftPercent + p * (nullIndex - j + 1);
307
+ }
308
+
309
+ nullIndex = 0;
310
+ }
311
+ }
312
+
313
+ return result;
314
+ }
282
315
 
283
- return steps
284
- .slice(index, index + 2)
285
- .concat(percent === 1 ? 1 : percent % (1 / count) * count);
316
+ function getStop(stops, percent) {
317
+ const index = findIndex(stops.slice(1), ([, targetPercent]) => percent <= targetPercent) + 1;
318
+ return [
319
+ stops[index - 1][0],
320
+ stops[index][0],
321
+ (percent - stops[index - 1][1]) / (stops[index][1] - stops[index - 1][1]),
322
+ ];
286
323
  }
287
324
 
288
- function getValue(steps, percent) {
289
- const [start, end, p] = getStep(steps, percent);
290
- return isNumber(start)
291
- ? start + Math.abs(start - end) * p * (start < end ? 1 : -1)
292
- : +end;
325
+ function getValue(stops, percent) {
326
+ const [start, end, p] = getStop(stops, percent);
327
+ return isNumber(start) ? start + Math.abs(start - end) * p * (start < end ? 1 : -1) : +end;
293
328
  }
294
329
 
295
- function getUnit(steps, defaultUnit) {
296
- return steps.reduce((unit, step) => unit || isString(step) && step.replace(/[\d-]/g, '').trim(), '') || defaultUnit;
330
+ const unitRe = /^-?\d+([^\s]*)/;
331
+ function getUnit(stops, defaultUnit) {
332
+ for (const stop of stops) {
333
+ const match = stop.match?.(unitRe);
334
+ if (match) {
335
+ return match[1];
336
+ }
337
+ }
338
+ return defaultUnit;
297
339
  }
298
340
 
299
341
  function getCssValue(el, prop, value) {
@@ -1,24 +1,31 @@
1
- import {$, flipPosition, offset as getOffset, isNumeric, isRtl, positionAt, removeClasses, toggleClass} from 'uikit-util';
1
+ import {
2
+ $,
3
+ flipPosition,
4
+ offset as getOffset,
5
+ isNumeric,
6
+ isRtl,
7
+ positionAt,
8
+ removeClasses,
9
+ toggleClass,
10
+ } from 'uikit-util';
2
11
 
3
12
  export default {
4
-
5
13
  props: {
6
14
  pos: String,
7
15
  offset: null,
8
16
  flip: Boolean,
9
- clsPos: String
17
+ clsPos: String,
10
18
  },
11
19
 
12
20
  data: {
13
21
  pos: `bottom-${isRtl ? 'right' : 'left'}`,
14
22
  flip: true,
15
23
  offset: false,
16
- clsPos: ''
24
+ clsPos: '',
17
25
  },
18
26
 
19
27
  computed: {
20
-
21
- pos({pos}) {
28
+ pos({ pos }) {
22
29
  return pos.split('-').concat('center').slice(0, 2);
23
30
  },
24
31
 
@@ -28,32 +35,34 @@ export default {
28
35
 
29
36
  align() {
30
37
  return this.pos[1];
31
- }
32
-
38
+ },
33
39
  },
34
40
 
35
41
  methods: {
36
-
37
42
  positionAt(element, target, boundary) {
38
-
39
43
  removeClasses(element, `${this.clsPos}-(top|bottom|left|right)(-[a-z]+)?`);
40
44
 
41
- let {offset} = this;
45
+ let { offset } = this;
42
46
  const axis = this.getAxis();
43
47
 
44
48
  if (!isNumeric(offset)) {
45
49
  const node = $(offset);
46
50
  offset = node
47
- ? getOffset(node)[axis === 'x' ? 'left' : 'top'] - getOffset(target)[axis === 'x' ? 'right' : 'bottom']
51
+ ? getOffset(node)[axis === 'x' ? 'left' : 'top'] -
52
+ getOffset(target)[axis === 'x' ? 'right' : 'bottom']
48
53
  : 0;
49
54
  }
50
55
 
51
- const {x, y} = positionAt(
56
+ const { x, y } = positionAt(
52
57
  element,
53
58
  target,
54
- axis === 'x' ? `${flipPosition(this.dir)} ${this.align}` : `${this.align} ${flipPosition(this.dir)}`,
59
+ axis === 'x'
60
+ ? `${flipPosition(this.dir)} ${this.align}`
61
+ : `${this.align} ${flipPosition(this.dir)}`,
55
62
  axis === 'x' ? `${this.dir} ${this.align}` : `${this.align} ${this.dir}`,
56
- axis === 'x' ? `${this.dir === 'left' ? -offset : offset}` : ` ${this.dir === 'top' ? -offset : offset}`,
63
+ axis === 'x'
64
+ ? `${this.dir === 'left' ? -offset : offset}`
65
+ : ` ${this.dir === 'top' ? -offset : offset}`,
57
66
  null,
58
67
  this.flip,
59
68
  boundary
@@ -63,13 +72,10 @@ export default {
63
72
  this.align = axis === 'x' ? y : x;
64
73
 
65
74
  toggleClass(element, `${this.clsPos}-${this.dir}-${this.align}`, this.offset === false);
66
-
67
75
  },
68
76
 
69
77
  getAxis() {
70
78
  return this.dir === 'top' || this.dir === 'bottom' ? 'y' : 'x';
71
- }
72
-
73
- }
74
-
79
+ },
80
+ },
75
81
  };
@@ -1,17 +1,16 @@
1
- import {$, attr, matches} from 'uikit-util';
1
+ import { $, attr, matches } from 'uikit-util';
2
2
 
3
3
  export default {
4
-
5
4
  props: {
6
5
  autoplay: Boolean,
7
6
  autoplayInterval: Number,
8
- pauseOnHover: Boolean
7
+ pauseOnHover: Boolean,
9
8
  },
10
9
 
11
10
  data: {
12
11
  autoplay: false,
13
12
  autoplayInterval: 7000,
14
- pauseOnHover: true
13
+ pauseOnHover: true,
15
14
  },
16
15
 
17
16
  connected() {
@@ -27,9 +26,7 @@ export default {
27
26
  },
28
27
 
29
28
  events: [
30
-
31
29
  {
32
-
33
30
  name: 'visibilitychange',
34
31
 
35
32
  el() {
@@ -46,32 +43,26 @@ export default {
46
43
  } else {
47
44
  this.startAutoplay();
48
45
  }
49
- }
50
-
51
- }
52
-
46
+ },
47
+ },
53
48
  ],
54
49
 
55
50
  methods: {
56
-
57
51
  startAutoplay() {
58
-
59
52
  this.stopAutoplay();
60
53
 
61
54
  this.interval = setInterval(
62
- () => (!this.draggable || !$(':focus', this.$el))
63
- && (!this.pauseOnHover || !matches(this.$el, ':hover'))
64
- && !this.stack.length
65
- && this.show('next'),
55
+ () =>
56
+ (!this.draggable || !$(':focus', this.$el)) &&
57
+ (!this.pauseOnHover || !matches(this.$el, ':hover')) &&
58
+ !this.stack.length &&
59
+ this.show('next'),
66
60
  this.autoplayInterval
67
61
  );
68
-
69
62
  },
70
63
 
71
64
  stopAutoplay() {
72
65
  this.interval && clearInterval(this.interval);
73
- }
74
-
75
- }
76
-
66
+ },
67
+ },
77
68
  };