uikit 3.11.2-dev.fb043abc2 → 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 +51 -20
  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 -361
  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 +5317 -6554
  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 +8018 -9698
  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 +16 -30
  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 +161 -128
  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 +58 -45
  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 +57 -72
  216. package/tests/sticky.html +14 -3
  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,39 +1,46 @@
1
- import {closest, css, getEventPos, includes, isRtl, isTouch, off, on, pointerCancel, pointerDown, pointerMove, pointerUp, selInput, trigger} from 'uikit-util';
1
+ import {
2
+ closest,
3
+ css,
4
+ getEventPos,
5
+ includes,
6
+ isRtl,
7
+ isTouch,
8
+ off,
9
+ on,
10
+ pointerCancel,
11
+ pointerDown,
12
+ pointerMove,
13
+ pointerUp,
14
+ selInput,
15
+ trigger,
16
+ } from 'uikit-util';
2
17
 
3
18
  export default {
4
-
5
19
  props: {
6
- draggable: Boolean
20
+ draggable: Boolean,
7
21
  },
8
22
 
9
23
  data: {
10
24
  draggable: true,
11
- threshold: 10
25
+ threshold: 10,
12
26
  },
13
27
 
14
28
  created() {
15
-
16
- ['start', 'move', 'end'].forEach(key => {
17
-
29
+ for (const key of ['start', 'move', 'end']) {
18
30
  const fn = this[key];
19
- this[key] = e => {
20
-
31
+ this[key] = (e) => {
21
32
  const pos = getEventPos(e).x * (isRtl ? -1 : 1);
22
33
 
23
- this.prevPos = pos !== this.pos ? this.pos : this.prevPos;
34
+ this.prevPos = pos === this.pos ? this.prevPos : this.pos;
24
35
  this.pos = pos;
25
36
 
26
37
  fn(e);
27
38
  };
28
-
29
- });
30
-
39
+ }
31
40
  },
32
41
 
33
42
  events: [
34
-
35
43
  {
36
-
37
44
  name: pointerDown,
38
45
 
39
46
  delegate() {
@@ -41,19 +48,18 @@ export default {
41
48
  },
42
49
 
43
50
  handler(e) {
44
-
45
- if (!this.draggable
46
- || !isTouch(e) && hasTextNodesOnly(e.target)
47
- || closest(e.target, selInput)
48
- || e.button > 0
49
- || this.length < 2
51
+ if (
52
+ !this.draggable ||
53
+ (!isTouch(e) && hasTextNodesOnly(e.target)) ||
54
+ closest(e.target, selInput) ||
55
+ e.button > 0 ||
56
+ this.length < 2
50
57
  ) {
51
58
  return;
52
59
  }
53
60
 
54
61
  this.start(e);
55
- }
56
-
62
+ },
57
63
  },
58
64
 
59
65
  {
@@ -61,19 +67,15 @@ export default {
61
67
 
62
68
  handler(e) {
63
69
  e.preventDefault();
64
- }
65
- }
66
-
70
+ },
71
+ },
67
72
  ],
68
73
 
69
74
  methods: {
70
-
71
75
  start() {
72
-
73
76
  this.drag = this.pos;
74
77
 
75
78
  if (this._transitioner) {
76
-
77
79
  this.percent = this._transitioner.percent();
78
80
  this.drag += this._transitioner.getDistance() * this.percent * this.dir;
79
81
 
@@ -83,25 +85,26 @@ export default {
83
85
  this.dragging = true;
84
86
 
85
87
  this.stack = [];
86
-
87
88
  } else {
88
89
  this.prevIndex = this.index;
89
90
  }
90
91
 
91
- on(document, pointerMove, this.move, {passive: false});
92
+ on(document, pointerMove, this.move, { passive: false });
92
93
 
93
94
  // 'input' event is triggered by video controls
94
95
  on(document, `${pointerUp} ${pointerCancel} input`, this.end, true);
95
96
 
96
97
  css(this.list, 'userSelect', 'none');
97
-
98
98
  },
99
99
 
100
100
  move(e) {
101
-
102
101
  const distance = this.pos - this.drag;
103
102
 
104
- if (distance === 0 || this.prevPos === this.pos || !this.dragging && Math.abs(distance) < this.threshold) {
103
+ if (
104
+ distance === 0 ||
105
+ this.prevPos === this.pos ||
106
+ (!this.dragging && Math.abs(distance) < this.threshold)
107
+ ) {
105
108
  return;
106
109
  }
107
110
 
@@ -111,23 +114,21 @@ export default {
111
114
  e.cancelable && e.preventDefault();
112
115
 
113
116
  this.dragging = true;
114
- this.dir = (distance < 0 ? 1 : -1);
117
+ this.dir = distance < 0 ? 1 : -1;
115
118
 
116
- const {slides} = this;
117
- let {prevIndex} = this;
119
+ const { slides } = this;
120
+ let { prevIndex } = this;
118
121
  let dis = Math.abs(distance);
119
122
  let nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);
120
123
  let width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;
121
124
 
122
125
  while (nextIndex !== prevIndex && dis > width) {
123
-
124
126
  this.drag -= width * this.dir;
125
127
 
126
128
  prevIndex = nextIndex;
127
129
  dis -= width;
128
130
  nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);
129
131
  width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;
130
-
131
132
  }
132
133
 
133
134
  this.percent = dis / width;
@@ -139,17 +140,18 @@ export default {
139
140
 
140
141
  let itemShown;
141
142
 
142
- [this.index, this.prevIndex].filter(i => !includes([nextIndex, prevIndex], i)).forEach(i => {
143
- trigger(slides[i], 'itemhidden', [this]);
144
-
145
- if (edge) {
146
- itemShown = true;
147
- this.prevIndex = prevIndex;
148
- }
143
+ [this.index, this.prevIndex]
144
+ .filter((i) => !includes([nextIndex, prevIndex], i))
145
+ .forEach((i) => {
146
+ trigger(slides[i], 'itemhidden', [this]);
149
147
 
150
- });
148
+ if (edge) {
149
+ itemShown = true;
150
+ this.prevIndex = prevIndex;
151
+ }
152
+ });
151
153
 
152
- if (this.index === prevIndex && this.prevIndex !== prevIndex || itemShown) {
154
+ if ((this.index === prevIndex && this.prevIndex !== prevIndex) || itemShown) {
153
155
  trigger(slides[this.index], 'itemshown', [this]);
154
156
  }
155
157
 
@@ -167,16 +169,13 @@ export default {
167
169
  !edge && trigger(prev, 'itemhide', [this]);
168
170
  trigger(next, 'itemshow', [this]);
169
171
  }
170
-
171
172
  },
172
173
 
173
174
  end() {
174
-
175
- off(document, pointerMove, this.move, {passive: false});
175
+ off(document, pointerMove, this.move, { passive: false });
176
176
  off(document, `${pointerUp} ${pointerCancel} input`, this.end, true);
177
177
 
178
178
  if (this.dragging) {
179
-
180
179
  this.dragging = null;
181
180
 
182
181
  if (this.index === this.prevIndex) {
@@ -185,29 +184,29 @@ export default {
185
184
  this._show(false, this.index, true);
186
185
  this._transitioner = null;
187
186
  } else {
188
-
189
- const dirChange = (isRtl ? this.dir * (isRtl ? 1 : -1) : this.dir) < 0 === this.prevPos > this.pos;
187
+ const dirChange =
188
+ (isRtl ? this.dir * (isRtl ? 1 : -1) : this.dir) < 0 ===
189
+ this.prevPos > this.pos;
190
190
  this.index = dirChange ? this.index : this.prevIndex;
191
191
 
192
192
  if (dirChange) {
193
193
  this.percent = 1 - this.percent;
194
194
  }
195
195
 
196
- this.show(this.dir > 0 && !dirChange || this.dir < 0 && dirChange ? 'next' : 'previous', true);
196
+ this.show(
197
+ (this.dir > 0 && !dirChange) || (this.dir < 0 && dirChange)
198
+ ? 'next'
199
+ : 'previous',
200
+ true
201
+ );
197
202
  }
198
-
199
203
  }
200
204
 
201
- css(this.list, {userSelect: '', pointerEvents: ''});
202
-
203
- this.drag
204
- = this.percent
205
- = null;
206
-
207
- }
208
-
209
- }
205
+ css(this.list, { userSelect: '', pointerEvents: '' });
210
206
 
207
+ this.drag = this.percent = null;
208
+ },
209
+ },
211
210
  };
212
211
 
213
212
  function hasTextNodesOnly(el) {
@@ -1,49 +1,45 @@
1
- import {$, $$, data, html, toggleClass, toNumber} from 'uikit-util';
1
+ import { $, $$, data, html, toggleClass, toNumber } from 'uikit-util';
2
2
 
3
3
  export default {
4
-
5
4
  data: {
6
- selNav: false
5
+ selNav: false,
7
6
  },
8
7
 
9
8
  computed: {
10
-
11
- nav({selNav}, $el) {
9
+ nav({ selNav }, $el) {
12
10
  return $(selNav, $el);
13
11
  },
14
12
 
15
- selNavItem({attrItem}) {
13
+ selNavItem({ attrItem }) {
16
14
  return `[${attrItem}],[data-${attrItem}]`;
17
15
  },
18
16
 
19
17
  navItems(_, $el) {
20
18
  return $$(this.selNavItem, $el);
21
- }
22
-
19
+ },
23
20
  },
24
21
 
25
22
  update: {
26
-
27
23
  write() {
28
-
29
24
  if (this.nav && this.length !== this.nav.children.length) {
30
- html(this.nav, this.slides.map((_, i) => `<li ${this.attrItem}="${i}"><a href></a></li>`).join(''));
25
+ html(
26
+ this.nav,
27
+ this.slides
28
+ .map((_, i) => `<li ${this.attrItem}="${i}"><a href></a></li>`)
29
+ .join('')
30
+ );
31
31
  }
32
32
 
33
- this.navItems.concat(this.nav).forEach(el => el && (el.hidden = !this.maxIndex));
33
+ this.navItems.concat(this.nav).forEach((el) => el && (el.hidden = !this.maxIndex));
34
34
 
35
35
  this.updateNav();
36
-
37
36
  },
38
37
 
39
- events: ['resize']
40
-
38
+ events: ['resize'],
41
39
  },
42
40
 
43
41
  events: [
44
-
45
42
  {
46
-
47
43
  name: 'click',
48
44
 
49
45
  delegate() {
@@ -53,34 +49,29 @@ export default {
53
49
  handler(e) {
54
50
  e.preventDefault();
55
51
  this.show(data(e.current, this.attrItem));
56
- }
57
-
52
+ },
58
53
  },
59
54
 
60
55
  {
61
-
62
56
  name: 'itemshow',
63
- handler: 'updateNav'
64
-
65
- }
66
-
57
+ handler: 'updateNav',
58
+ },
67
59
  ],
68
60
 
69
61
  methods: {
70
-
71
62
  updateNav() {
72
-
73
63
  const i = this.getValidIndex();
74
- this.navItems.forEach(el => {
75
-
64
+ for (const el of this.navItems) {
76
65
  const cmd = data(el, this.attrItem);
77
66
 
78
67
  toggleClass(el, this.clsActive, toNumber(cmd) === i);
79
- toggleClass(el, 'uk-invisible', this.finite && (cmd === 'previous' && i === 0 || cmd === 'next' && i >= this.maxIndex));
80
- });
81
-
82
- }
83
-
84
- }
85
-
68
+ toggleClass(
69
+ el,
70
+ 'uk-invisible',
71
+ this.finite &&
72
+ ((cmd === 'previous' && i === 0) || (cmd === 'next' && i >= this.maxIndex))
73
+ );
74
+ }
75
+ },
76
+ },
86
77
  };
@@ -1,9 +1,6 @@
1
1
  export default {
2
-
3
2
  update: {
4
-
5
3
  write() {
6
-
7
4
  if (this.stack.length || this.dragging) {
8
5
  return;
9
6
  }
@@ -13,11 +10,8 @@ export default {
13
10
  if (!~this.prevIndex || this.index !== index) {
14
11
  this.show(index);
15
12
  }
16
-
17
13
  },
18
14
 
19
- events: ['resize']
20
-
21
- }
22
-
15
+ events: ['resize'],
16
+ },
23
17
  };
@@ -1,10 +1,20 @@
1
1
  import SliderAutoplay from './slider-autoplay';
2
2
  import SliderDrag from './slider-drag';
3
3
  import SliderNav from './slider-nav';
4
- import {$, $$, assign, clamp, fastdom, getIndex, hasClass, isNumber, isRtl, Promise, removeClass, trigger} from 'uikit-util';
4
+ import {
5
+ $,
6
+ $$,
7
+ clamp,
8
+ fastdom,
9
+ getIndex,
10
+ hasClass,
11
+ isNumber,
12
+ isRtl,
13
+ removeClass,
14
+ trigger,
15
+ } from 'uikit-util';
5
16
 
6
17
  export default {
7
-
8
18
  mixins: [SliderAutoplay, SliderDrag, SliderNav],
9
19
 
10
20
  props: {
@@ -13,7 +23,7 @@ export default {
13
23
  index: Number,
14
24
  finite: Boolean,
15
25
  velocity: Number,
16
- selSlides: String
26
+ selSlides: String,
17
27
  },
18
28
 
19
29
  data: () => ({
@@ -27,7 +37,7 @@ export default {
27
37
  clsActive: 'uk-active',
28
38
  clsActivated: false,
29
39
  Transitioner: false,
30
- transitionOptions: {}
40
+ transitionOptions: {},
31
41
  }),
32
42
 
33
43
  connected() {
@@ -41,12 +51,11 @@ export default {
41
51
  },
42
52
 
43
53
  computed: {
44
-
45
- duration({velocity}, $el) {
54
+ duration({ velocity }, $el) {
46
55
  return speedUp($el.offsetWidth / velocity);
47
56
  },
48
57
 
49
- list({selList}, $el) {
58
+ list({ selList }, $el) {
50
59
  return $(selList, $el);
51
60
  },
52
61
 
@@ -54,45 +63,32 @@ export default {
54
63
  return this.length - 1;
55
64
  },
56
65
 
57
- selSlides({selList, selSlides}) {
66
+ selSlides({ selList, selSlides }) {
58
67
  return `${selList} ${selSlides || '> *'}`;
59
68
  },
60
69
 
61
70
  slides: {
62
-
63
71
  get() {
64
72
  return $$(this.selSlides, this.$el);
65
73
  },
66
74
 
67
75
  watch() {
68
76
  this.$reset();
69
- }
70
-
77
+ },
71
78
  },
72
79
 
73
80
  length() {
74
81
  return this.slides.length;
75
- }
76
-
77
- },
78
-
79
- events: {
80
-
81
- itemshown() {
82
- this.$update(this.list);
83
- }
84
-
82
+ },
85
83
  },
86
84
 
87
85
  methods: {
88
-
89
86
  show(index, force = false) {
90
-
91
87
  if (this.dragging || !this.length) {
92
88
  return;
93
89
  }
94
90
 
95
- const {stack} = this;
91
+ const { stack } = this;
96
92
  const queueIndex = force ? 0 : stack.length;
97
93
  const reset = () => {
98
94
  stack.splice(queueIndex, 1);
@@ -105,7 +101,6 @@ export default {
105
101
  stack[force ? 'unshift' : 'push'](index);
106
102
 
107
103
  if (!force && stack.length > 1) {
108
-
109
104
  if (stack.length === 2) {
110
105
  this._transitioner.forward(Math.min(this.duration, 200));
111
106
  }
@@ -127,8 +122,9 @@ export default {
127
122
  this.prevIndex = prevIndex;
128
123
  this.index = nextIndex;
129
124
 
130
- if (prev && !trigger(prev, 'beforeitemhide', [this])
131
- || !trigger(next, 'beforeitemshow', [this, prev])
125
+ if (
126
+ (prev && !trigger(prev, 'beforeitemhide', [this])) ||
127
+ !trigger(next, 'beforeitemshow', [this, prev])
132
128
  ) {
133
129
  this.index = this.prevIndex;
134
130
  reset();
@@ -136,11 +132,10 @@ export default {
136
132
  }
137
133
 
138
134
  const promise = this._show(prev, next, force).then(() => {
139
-
140
135
  prev && trigger(prev, 'itemhidden', [this]);
141
136
  trigger(next, 'itemshown', [this]);
142
137
 
143
- return new Promise(resolve => {
138
+ return new Promise((resolve) => {
144
139
  fastdom.write(() => {
145
140
  stack.shift();
146
141
  if (stack.length) {
@@ -151,14 +146,12 @@ export default {
151
146
  resolve();
152
147
  });
153
148
  });
154
-
155
149
  });
156
150
 
157
151
  prev && trigger(prev, 'itemhide', [this]);
158
152
  trigger(next, 'itemshow', [this]);
159
153
 
160
154
  return promise;
161
-
162
155
  },
163
156
 
164
157
  getIndex(index = this.index, prev = this.index) {
@@ -170,28 +163,25 @@ export default {
170
163
  },
171
164
 
172
165
  _show(prev, next, force) {
173
-
174
- this._transitioner = this._getTransitioner(
175
- prev,
176
- next,
177
- this.dir,
178
- assign({
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
- }, this.transitionOptions)
185
- );
166
+ this._transitioner = this._getTransitioner(prev, next, this.dir, {
167
+ easing: force
168
+ ? next.offsetWidth < 600
169
+ ? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
170
+ : 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
171
+ : this.easing,
172
+ ...this.transitionOptions,
173
+ });
186
174
 
187
175
  if (!force && !prev) {
188
176
  this._translate(1);
189
177
  return Promise.resolve();
190
178
  }
191
179
 
192
- const {length} = this.stack;
193
- return this._transitioner[length > 1 ? 'forward' : 'show'](length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration, this.percent);
194
-
180
+ const { length } = this.stack;
181
+ return this._transitioner[length > 1 ? 'forward' : 'show'](
182
+ length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration,
183
+ this.percent
184
+ );
195
185
  },
196
186
 
197
187
  _getDistance(prev, next) {
@@ -204,29 +194,26 @@ export default {
204
194
  return transitioner;
205
195
  },
206
196
 
207
- _getTransitioner(prev = this.prevIndex, next = this.index, dir = this.dir || 1, options = this.transitionOptions) {
197
+ _getTransitioner(
198
+ prev = this.prevIndex,
199
+ next = this.index,
200
+ dir = this.dir || 1,
201
+ options = this.transitionOptions
202
+ ) {
208
203
  return new this.Transitioner(
209
204
  isNumber(prev) ? this.slides[prev] : prev,
210
205
  isNumber(next) ? this.slides[next] : next,
211
206
  dir * (isRtl ? -1 : 1),
212
207
  options
213
208
  );
214
- }
215
-
216
- }
217
-
209
+ },
210
+ },
218
211
  };
219
212
 
220
213
  function getDirection(index, prevIndex) {
221
- return index === 'next'
222
- ? 1
223
- : index === 'previous'
224
- ? -1
225
- : index < prevIndex
226
- ? -1
227
- : 1;
214
+ return index === 'next' ? 1 : index === 'previous' ? -1 : index < prevIndex ? -1 : 1;
228
215
  }
229
216
 
230
217
  export function speedUp(x) {
231
- return .5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)
218
+ return 0.5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)
232
219
  }
@@ -1,53 +1,43 @@
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
-
8
7
  mixins: [Slider],
9
8
 
10
9
  props: {
11
- animation: String
10
+ animation: String,
12
11
  },
13
12
 
14
13
  data: {
15
14
  animation: 'slide',
16
15
  clsActivated: 'uk-transition-active',
17
16
  Animations,
18
- Transitioner
17
+ Transitioner,
19
18
  },
20
19
 
21
20
  computed: {
22
-
23
- animation({animation, Animations}) {
24
- return assign(Animations[animation] || Animations.slide, {name: animation});
21
+ animation({ animation, Animations }) {
22
+ return { ...(Animations[animation] || Animations.slide), name: animation };
25
23
  },
26
24
 
27
25
  transitionOptions() {
28
- return {animation: this.animation};
29
- }
30
-
26
+ return { animation: this.animation };
27
+ },
31
28
  },
32
29
 
33
30
  events: {
34
-
35
- 'itemshow itemhide itemshown itemhidden'({target}) {
36
- this.$update(target);
37
- },
38
-
39
- beforeitemshow({target}) {
31
+ beforeitemshow({ target }) {
40
32
  addClass(target, this.clsActive);
41
33
  },
42
34
 
43
- itemshown({target}) {
35
+ itemshown({ target }) {
44
36
  addClass(target, this.clsActivated);
45
37
  },
46
38
 
47
- itemhidden({target}) {
39
+ itemhidden({ target }) {
48
40
  removeClass(target, this.clsActive, this.clsActivated);
49
- }
50
-
51
- }
52
-
41
+ },
42
+ },
53
43
  };