uikit 3.11.2-dev.fb043abc2 → 3.12.2

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 (228) 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 +63 -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 +144 -202
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +144 -202
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +146 -208
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +146 -208
  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/list.less +5 -1
  164. package/src/less/components/modal.less +3 -7
  165. package/src/less/components/navbar.less +0 -7
  166. package/src/less/components/progress.less +14 -36
  167. package/src/less/components/slider.less +3 -3
  168. package/src/less/components/slideshow.less +3 -3
  169. package/src/less/components/text.less +16 -32
  170. package/src/less/components/utility.less +25 -0
  171. package/src/scss/components/base.scss +10 -33
  172. package/src/scss/components/flex.scss +0 -9
  173. package/src/scss/components/form-range.scss +48 -95
  174. package/src/scss/components/form.scss +3 -4
  175. package/src/scss/components/height.scss +3 -0
  176. package/src/scss/components/icon.scss +2 -2
  177. package/src/scss/components/leader.scss +0 -1
  178. package/src/scss/components/lightbox.scss +0 -1
  179. package/src/scss/components/list.scss +5 -1
  180. package/src/scss/components/modal.scss +3 -7
  181. package/src/scss/components/navbar.scss +0 -7
  182. package/src/scss/components/progress.scss +14 -36
  183. package/src/scss/components/search.scss +1 -1
  184. package/src/scss/components/slider.scss +3 -3
  185. package/src/scss/components/slideshow.scss +3 -3
  186. package/src/scss/components/text.scss +16 -32
  187. package/src/scss/components/utility.scss +25 -0
  188. package/src/scss/mixins-theme.scss +1 -1
  189. package/src/scss/mixins.scss +1 -1
  190. package/src/scss/variables-theme.scss +9 -9
  191. package/src/scss/variables.scss +9 -9
  192. package/tests/align.html +10 -10
  193. package/tests/animation.html +2 -2
  194. package/tests/article.html +2 -2
  195. package/tests/base.html +3 -3
  196. package/tests/card.html +10 -10
  197. package/tests/column.html +3 -3
  198. package/tests/comment.html +9 -9
  199. package/tests/countdown.html +10 -8
  200. package/tests/dotnav.html +3 -3
  201. package/tests/image.html +296 -64
  202. package/tests/images/image-type.avif +0 -0
  203. package/tests/images/image-type.jpeg +0 -0
  204. package/tests/images/image-type.webp +0 -0
  205. package/tests/index.html +8 -8
  206. package/tests/js/index.js +114 -85
  207. package/tests/lightbox.html +10 -10
  208. package/tests/marker.html +2 -2
  209. package/tests/modal.html +8 -9
  210. package/tests/navbar.html +2 -2
  211. package/tests/overlay.html +7 -7
  212. package/tests/parallax.html +16 -7
  213. package/tests/position.html +12 -12
  214. package/tests/slidenav.html +12 -12
  215. package/tests/slider.html +20 -20
  216. package/tests/sortable.html +1 -1
  217. package/tests/sticky-parallax.html +57 -72
  218. package/tests/sticky.html +14 -3
  219. package/tests/svg.html +6 -6
  220. package/tests/table.html +11 -11
  221. package/tests/thumbnav.html +12 -12
  222. package/tests/transition.html +30 -30
  223. package/tests/utility.html +50 -33
  224. package/tests/video.html +1 -1
  225. package/tests/width.html +1 -1
  226. package/src/js/mixin/flex-bug.js +0 -56
  227. package/src/js/util/promise.js +0 -191
  228. package/tests/images/animated.gif +0 -0
@@ -1,16 +1,29 @@
1
1
  import Modal from '../mixin/modal';
2
- import {$, addClass, append, css, endsWith, hasClass, height, isVisible, parent, removeClass, unwrap, wrapAll} from 'uikit-util';
2
+ import Swipe from '../mixin/swipe';
3
+ import {
4
+ $,
5
+ addClass,
6
+ append,
7
+ css,
8
+ endsWith,
9
+ hasClass,
10
+ height,
11
+ isVisible,
12
+ parent,
13
+ removeClass,
14
+ unwrap,
15
+ wrapAll,
16
+ } from 'uikit-util';
3
17
 
4
18
  export default {
5
-
6
- mixins: [Modal],
19
+ mixins: [Modal, Swipe],
7
20
 
8
21
  args: 'mode',
9
22
 
10
23
  props: {
11
24
  mode: String,
12
25
  flip: Boolean,
13
- overlay: Boolean
26
+ overlay: Boolean,
14
27
  },
15
28
 
16
29
  data: {
@@ -26,65 +39,58 @@ export default {
26
39
  clsMode: 'uk-offcanvas',
27
40
  clsOverlay: 'uk-offcanvas-overlay',
28
41
  selClose: '.uk-offcanvas-close',
29
- container: false
42
+ container: false,
30
43
  },
31
44
 
32
45
  computed: {
33
-
34
- clsFlip({flip, clsFlip}) {
46
+ clsFlip({ flip, clsFlip }) {
35
47
  return flip ? clsFlip : '';
36
48
  },
37
49
 
38
- clsOverlay({overlay, clsOverlay}) {
50
+ clsOverlay({ overlay, clsOverlay }) {
39
51
  return overlay ? clsOverlay : '';
40
52
  },
41
53
 
42
- clsMode({mode, clsMode}) {
54
+ clsMode({ mode, clsMode }) {
43
55
  return `${clsMode}-${mode}`;
44
56
  },
45
57
 
46
- clsSidebarAnimation({mode, clsSidebarAnimation}) {
58
+ clsSidebarAnimation({ mode, clsSidebarAnimation }) {
47
59
  return mode === 'none' || mode === 'reveal' ? '' : clsSidebarAnimation;
48
60
  },
49
61
 
50
- clsContainerAnimation({mode, clsContainerAnimation}) {
62
+ clsContainerAnimation({ mode, clsContainerAnimation }) {
51
63
  return mode !== 'push' && mode !== 'reveal' ? '' : clsContainerAnimation;
52
64
  },
53
65
 
54
- transitionElement({mode}) {
66
+ transitionElement({ mode }) {
55
67
  return mode === 'reveal' ? parent(this.panel) : this.panel;
56
- }
57
-
68
+ },
58
69
  },
59
70
 
60
71
  update: {
61
-
62
72
  read() {
63
73
  if (this.isToggled() && !isVisible(this.$el)) {
64
74
  this.hide();
65
75
  }
66
76
  },
67
77
 
68
- events: ['resize']
69
-
78
+ events: ['resize'],
70
79
  },
71
80
 
72
81
  events: [
73
-
74
82
  {
75
-
76
83
  name: 'click',
77
84
 
78
85
  delegate() {
79
86
  return 'a[href^="#"]';
80
87
  },
81
88
 
82
- handler({current: {hash}, defaultPrevented}) {
89
+ handler({ current: { hash }, defaultPrevented }) {
83
90
  if (!defaultPrevented && hash && $(hash, document.body)) {
84
91
  this.hide();
85
92
  }
86
- }
87
-
93
+ },
88
94
  },
89
95
 
90
96
  {
@@ -96,14 +102,11 @@ export default {
96
102
  return this.panel;
97
103
  },
98
104
 
99
- handler({targetTouches}) {
100
-
105
+ handler({ targetTouches }) {
101
106
  if (targetTouches.length === 1) {
102
107
  this.clientY = targetTouches[0].clientY;
103
108
  }
104
-
105
- }
106
-
109
+ },
107
110
  },
108
111
 
109
112
  {
@@ -118,8 +121,7 @@ export default {
118
121
 
119
122
  handler(e) {
120
123
  e.cancelable && e.preventDefault();
121
- }
122
-
124
+ },
123
125
  },
124
126
 
125
127
  {
@@ -132,23 +134,21 @@ export default {
132
134
  },
133
135
 
134
136
  handler(e) {
135
-
136
137
  if (e.targetTouches.length !== 1) {
137
138
  return;
138
139
  }
139
140
 
140
141
  const clientY = e.targetTouches[0].clientY - this.clientY;
141
- const {scrollTop, scrollHeight, clientHeight} = this.panel;
142
+ const { scrollTop, scrollHeight, clientHeight } = this.panel;
142
143
 
143
- if (clientHeight >= scrollHeight
144
- || scrollTop === 0 && clientY > 0
145
- || scrollHeight - scrollTop <= clientHeight && clientY < 0
144
+ if (
145
+ clientHeight >= scrollHeight ||
146
+ (scrollTop === 0 && clientY > 0) ||
147
+ (scrollHeight - scrollTop <= clientHeight && clientY < 0)
146
148
  ) {
147
149
  e.cancelable && e.preventDefault();
148
150
  }
149
-
150
- }
151
-
151
+ },
152
152
  },
153
153
 
154
154
  {
@@ -157,7 +157,6 @@ export default {
157
157
  self: true,
158
158
 
159
159
  handler() {
160
-
161
160
  if (this.mode === 'reveal' && !hasClass(parent(this.panel), this.clsMode)) {
162
161
  wrapAll(this.panel, '<div>');
163
162
  addClass(parent(this.panel), this.clsMode);
@@ -168,15 +167,17 @@ export default {
168
167
  css(document.body, 'touch-action', 'pan-y pinch-zoom');
169
168
  css(this.$el, 'display', 'block');
170
169
  addClass(this.$el, this.clsOverlay);
171
- addClass(this.panel, this.clsSidebarAnimation, this.mode !== 'reveal' ? this.clsMode : '');
170
+ addClass(
171
+ this.panel,
172
+ this.clsSidebarAnimation,
173
+ this.mode !== 'reveal' ? this.clsMode : ''
174
+ );
172
175
 
173
176
  height(document.body); // force reflow
174
177
  addClass(document.body, this.clsContainerAnimation);
175
178
 
176
179
  this.clsContainerAnimation && suppressUserScale();
177
-
178
-
179
- }
180
+ },
180
181
  },
181
182
 
182
183
  {
@@ -187,7 +188,7 @@ export default {
187
188
  handler() {
188
189
  removeClass(document.body, this.clsContainerAnimation);
189
190
  css(document.body, 'touch-action', '');
190
- }
191
+ },
191
192
  },
192
193
 
193
194
  {
@@ -196,7 +197,6 @@ export default {
196
197
  self: true,
197
198
 
198
199
  handler() {
199
-
200
200
  this.clsContainerAnimation && resumeUserScale();
201
201
 
202
202
  if (this.mode === 'reveal') {
@@ -209,24 +209,19 @@ export default {
209
209
  removeClass(document.body, this.clsContainer, this.clsFlip);
210
210
 
211
211
  css(document.documentElement, 'overflowY', '');
212
-
213
- }
212
+ },
214
213
  },
215
214
 
216
215
  {
217
216
  name: 'swipeLeft swipeRight',
218
217
 
219
218
  handler(e) {
220
-
221
219
  if (this.isToggled() && endsWith(e.type, 'Left') ^ this.flip) {
222
220
  this.hide();
223
221
  }
224
-
225
- }
226
- }
227
-
228
- ]
229
-
222
+ },
223
+ },
224
+ ],
230
225
  };
231
226
 
232
227
  // Chrome in responsive mode zooms page upon opening offcanvas
@@ -240,5 +235,7 @@ function resumeUserScale() {
240
235
  }
241
236
 
242
237
  function getViewport() {
243
- return $('meta[name="viewport"]', document.head) || append(document.head, '<meta name="viewport">');
238
+ return (
239
+ $('meta[name="viewport"]', document.head) || append(document.head, '<meta name="viewport">')
240
+ );
244
241
  }
@@ -1,32 +1,29 @@
1
1
  import Class from '../mixin/class';
2
- import {closest, css, dimensions, height, isVisible, toFloat, trigger} from 'uikit-util';
2
+ import { closest, css, dimensions, height, isVisible, toFloat, trigger } from 'uikit-util';
3
3
 
4
4
  export default {
5
-
6
5
  mixins: [Class],
7
6
 
8
7
  props: {
9
8
  selContainer: String,
10
9
  selContent: String,
11
- minHeight: Number
10
+ minHeight: Number,
12
11
  },
13
12
 
14
13
  data: {
15
14
  selContainer: '.uk-modal',
16
15
  selContent: '.uk-modal-dialog',
17
- minHeight: 150
16
+ minHeight: 150,
18
17
  },
19
18
 
20
19
  computed: {
21
-
22
- container({selContainer}, $el) {
20
+ container({ selContainer }, $el) {
23
21
  return closest($el, selContainer);
24
22
  },
25
23
 
26
- content({selContent}, $el) {
24
+ content({ selContent }, $el) {
27
25
  return closest($el, selContent);
28
- }
29
-
26
+ },
30
27
  },
31
28
 
32
29
  connected() {
@@ -34,28 +31,27 @@ export default {
34
31
  },
35
32
 
36
33
  update: {
37
-
38
34
  read() {
39
-
40
35
  if (!this.content || !this.container || !isVisible(this.$el)) {
41
36
  return false;
42
37
  }
43
38
 
44
39
  return {
45
40
  current: toFloat(css(this.$el, 'maxHeight')),
46
- max: Math.max(this.minHeight, height(this.container) - (dimensions(this.content).height - height(this.$el)))
41
+ max: Math.max(
42
+ this.minHeight,
43
+ height(this.container) - (dimensions(this.content).height - height(this.$el))
44
+ ),
47
45
  };
48
46
  },
49
47
 
50
- write({current, max}) {
48
+ write({ current, max }) {
51
49
  css(this.$el, 'maxHeight', max);
52
50
  if (Math.round(current) !== Math.round(max)) {
53
51
  trigger(this.$el, 'resize');
54
52
  }
55
53
  },
56
54
 
57
- events: ['resize']
58
-
59
- }
60
-
55
+ events: ['resize'],
56
+ },
61
57
  };
@@ -1,7 +1,6 @@
1
- import {addClass, Dimensions, height, isVisible, parent, width} from 'uikit-util';
1
+ import { addClass, Dimensions, height, isVisible, parent, width } from 'uikit-util';
2
2
 
3
3
  export default {
4
-
5
4
  props: ['width', 'height'],
6
5
 
7
6
  connected() {
@@ -9,22 +8,25 @@ export default {
9
8
  },
10
9
 
11
10
  update: {
12
-
13
11
  read() {
14
12
  return isVisible(this.$el) && this.width && this.height
15
- ? {width: width(parent(this.$el)), height: this.height}
13
+ ? { width: width(parent(this.$el)), height: this.height }
16
14
  : false;
17
15
  },
18
16
 
19
17
  write(dim) {
20
- height(this.$el, Dimensions.contain({
21
- height: this.height,
22
- width: this.width
23
- }, dim).height);
18
+ height(
19
+ this.$el,
20
+ Dimensions.contain(
21
+ {
22
+ height: this.height,
23
+ width: this.width,
24
+ },
25
+ dim
26
+ ).height
27
+ );
24
28
  },
25
29
 
26
- events: ['resize']
27
-
28
- }
29
-
30
+ events: ['resize'],
31
+ },
30
32
  };
@@ -1,43 +1,33 @@
1
- import {$, escape, scrollIntoView, trigger} from 'uikit-util';
1
+ import { $, escape, scrollIntoView, trigger } from 'uikit-util';
2
2
 
3
3
  export default {
4
-
5
4
  props: {
6
- offset: Number
5
+ offset: Number,
7
6
  },
8
7
 
9
8
  data: {
10
- offset: 0
9
+ offset: 0,
11
10
  },
12
11
 
13
12
  methods: {
14
-
15
- scrollTo(el) {
16
-
17
- el = el && $(el) || document.body;
13
+ async scrollTo(el) {
14
+ el = (el && $(el)) || document.body;
18
15
 
19
16
  if (trigger(this.$el, 'beforescroll', [this, el])) {
20
- scrollIntoView(el, {offset: this.offset}).then(() =>
21
- trigger(this.$el, 'scrolled', [this, el])
22
- );
17
+ await scrollIntoView(el, { offset: this.offset });
18
+ trigger(this.$el, 'scrolled', [this, el]);
23
19
  }
24
-
25
- }
26
-
20
+ },
27
21
  },
28
22
 
29
23
  events: {
30
-
31
24
  click(e) {
32
-
33
25
  if (e.defaultPrevented) {
34
26
  return;
35
27
  }
36
28
 
37
29
  e.preventDefault();
38
30
  this.scrollTo(`#${escape(decodeURIComponent((this.$el.hash || '').substr(1)))}`);
39
- }
40
-
41
- }
42
-
31
+ },
32
+ },
43
33
  };
@@ -1,13 +1,25 @@
1
- import {$$, addClass, closest, escape, getViewport, getViewportClientHeight, hasClass, isVisible, offset, removeClass, scrollParents, trigger} from 'uikit-util';
1
+ import {
2
+ $$,
3
+ addClass,
4
+ closest,
5
+ escape,
6
+ getViewport,
7
+ getViewportClientHeight,
8
+ hasClass,
9
+ isVisible,
10
+ offset,
11
+ removeClass,
12
+ scrollParents,
13
+ trigger,
14
+ } from 'uikit-util';
2
15
 
3
16
  export default {
4
-
5
17
  props: {
6
18
  cls: String,
7
19
  closest: String,
8
20
  scroll: Boolean,
9
21
  overflow: Boolean,
10
- offset: Number
22
+ offset: Number,
11
23
  },
12
24
 
13
25
  data: {
@@ -15,60 +27,55 @@ export default {
15
27
  closest: false,
16
28
  scroll: false,
17
29
  overflow: true,
18
- offset: 0
30
+ offset: 0,
19
31
  },
20
32
 
21
33
  computed: {
22
-
23
34
  links: {
24
-
25
35
  get(_, $el) {
26
- return $$('a[href^="#"]', $el).filter(el => el.hash);
36
+ return $$('a[href^="#"]', $el).filter((el) => el.hash);
27
37
  },
28
38
 
29
39
  watch(links) {
30
40
  if (this.scroll) {
31
- this.$create('scroll', links, {offset: this.offset || 0});
41
+ this.$create('scroll', links, { offset: this.offset || 0 });
32
42
  }
33
43
  },
34
44
 
35
- immediate: true
36
-
45
+ immediate: true,
37
46
  },
38
47
 
39
48
  targets() {
40
- return $$(this.links.map(el => escape(el.hash).substr(1)).join(','));
49
+ return $$(this.links.map((el) => escape(el.hash).substr(1)).join(','));
41
50
  },
42
51
 
43
- elements({closest: selector}) {
52
+ elements({ closest: selector }) {
44
53
  return closest(this.links, selector || '*');
45
- }
46
-
54
+ },
47
55
  },
48
56
 
49
57
  update: [
50
-
51
58
  {
52
-
53
59
  read() {
54
-
55
- const {length} = this.targets;
60
+ const { length } = this.targets;
56
61
 
57
62
  if (!length || !isVisible(this.$el)) {
58
63
  return false;
59
64
  }
60
65
 
61
66
  const [scrollElement] = scrollParents(this.targets, /auto|scroll/, true);
62
- const {scrollTop, scrollHeight} = scrollElement;
67
+ const { scrollTop, scrollHeight } = scrollElement;
63
68
  const max = scrollHeight - getViewportClientHeight(scrollElement);
64
69
  let active = false;
65
70
 
66
71
  if (scrollTop === max) {
67
72
  active = length - 1;
68
73
  } else {
69
-
70
74
  this.targets.every((el, i) => {
71
- if (offset(el).top - offset(getViewport(scrollElement)).top - this.offset <= 0) {
75
+ if (
76
+ offset(el).top - offset(getViewport(scrollElement)).top - this.offset <=
77
+ 0
78
+ ) {
72
79
  active = i;
73
80
  return true;
74
81
  }
@@ -79,14 +86,13 @@ export default {
79
86
  }
80
87
  }
81
88
 
82
- return {active};
89
+ return { active };
83
90
  },
84
91
 
85
- write({active}) {
86
-
92
+ write({ active }) {
87
93
  const changed = active !== false && !hasClass(this.elements[active], this.cls);
88
94
 
89
- this.links.forEach(el => el.blur());
95
+ this.links.forEach((el) => el.blur());
90
96
  removeClass(this.elements, this.cls);
91
97
  addClass(this.elements[active], this.cls);
92
98
 
@@ -95,10 +101,7 @@ export default {
95
101
  }
96
102
  },
97
103
 
98
- events: ['scroll', 'resize']
99
-
100
- }
101
-
102
- ]
103
-
104
+ events: ['scroll', 'resize'],
105
+ },
106
+ ],
104
107
  };