uikit 3.11.1 → 3.11.2-dev.03e47c2ff

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 (222) 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 +59 -17
  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 +127 -201
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +127 -201
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +129 -207
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +129 -207
  25. package/dist/css/uikit.min.css +1 -1
  26. package/dist/js/components/countdown.js +88 -133
  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 +1098 -1316
  31. package/dist/js/components/lightbox-panel.min.js +1 -1
  32. package/dist/js/components/lightbox.js +1144 -1393
  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 +345 -362
  37. package/dist/js/components/parallax.min.js +1 -1
  38. package/dist/js/components/slider-parallax.js +343 -350
  39. package/dist/js/components/slider-parallax.min.js +1 -1
  40. package/dist/js/components/slider.js +768 -843
  41. package/dist/js/components/slider.min.js +1 -1
  42. package/dist/js/components/slideshow-parallax.js +343 -350
  43. package/dist/js/components/slideshow-parallax.min.js +1 -1
  44. package/dist/js/components/slideshow.js +645 -793
  45. package/dist/js/components/slideshow.min.js +1 -1
  46. package/dist/js/components/sortable.js +587 -621
  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 +155 -167
  51. package/dist/js/components/upload.min.js +1 -1
  52. package/dist/js/uikit-core.js +5430 -6690
  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 +8143 -9784
  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 +79 -100
  66. package/src/js/components/countdown.js +24 -50
  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 +37 -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 +95 -64
  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 +126 -108
  82. package/src/js/components/tooltip.js +41 -31
  83. package/src/js/components/upload.js +52 -63
  84. package/src/js/core/accordion.js +53 -48
  85. package/src/js/core/alert.js +9 -17
  86. package/src/js/core/core.js +74 -53
  87. package/src/js/core/cover.js +11 -15
  88. package/src/js/core/drop.js +107 -93
  89. package/src/js/core/form-custom.js +20 -25
  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 +29 -36
  94. package/src/js/core/icon.js +47 -52
  95. package/src/js/core/img.js +156 -138
  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 +49 -53
  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 +194 -123
  109. package/src/js/core/svg.js +68 -83
  110. package/src/js/core/switcher.js +47 -46
  111. package/src/js/core/tab.js +7 -10
  112. package/src/js/core/toggle.js +66 -67
  113. package/src/js/core/video.js +11 -22
  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/media.js +5 -10
  122. package/src/js/mixin/modal.js +89 -66
  123. package/src/js/mixin/parallax.js +175 -121
  124. package/src/js/mixin/position.js +26 -20
  125. package/src/js/mixin/slider-autoplay.js +12 -21
  126. package/src/js/mixin/slider-drag.js +64 -65
  127. package/src/js/mixin/slider-nav.js +26 -35
  128. package/src/js/mixin/slider-reactive.js +2 -8
  129. package/src/js/mixin/slider.js +48 -55
  130. package/src/js/mixin/slideshow.js +13 -19
  131. package/src/js/mixin/togglable.js +89 -63
  132. package/src/js/uikit-core.js +2 -4
  133. package/src/js/uikit.js +2 -4
  134. package/src/js/util/ajax.js +25 -40
  135. package/src/js/util/animation.js +77 -75
  136. package/src/js/util/attr.js +17 -21
  137. package/src/js/util/class.js +14 -52
  138. package/src/js/util/dimensions.js +78 -49
  139. package/src/js/util/dom.js +39 -66
  140. package/src/js/util/env.js +7 -12
  141. package/src/js/util/event.js +60 -59
  142. package/src/js/util/fastdom.js +3 -8
  143. package/src/js/util/filter.js +17 -34
  144. package/src/js/util/index.js +0 -1
  145. package/src/js/util/lang.js +82 -121
  146. package/src/js/util/mouse.js +19 -17
  147. package/src/js/util/options.js +35 -49
  148. package/src/js/util/player.js +41 -36
  149. package/src/js/util/position.js +54 -46
  150. package/src/js/util/selector.js +43 -58
  151. package/src/js/util/style.js +39 -49
  152. package/src/js/util/viewport.js +81 -66
  153. package/src/less/components/base.less +10 -33
  154. package/src/less/components/flex.less +0 -9
  155. package/src/less/components/form-range.less +48 -95
  156. package/src/less/components/form.less +0 -1
  157. package/src/less/components/height.less +3 -0
  158. package/src/less/components/leader.less +0 -1
  159. package/src/less/components/lightbox.less +0 -1
  160. package/src/less/components/modal.less +3 -7
  161. package/src/less/components/navbar.less +0 -7
  162. package/src/less/components/progress.less +14 -36
  163. package/src/less/components/slider.less +0 -3
  164. package/src/less/components/slideshow.less +0 -3
  165. package/src/less/components/text.less +16 -32
  166. package/src/less/components/utility.less +22 -0
  167. package/src/scss/components/base.scss +10 -33
  168. package/src/scss/components/flex.scss +0 -9
  169. package/src/scss/components/form-range.scss +48 -95
  170. package/src/scss/components/form.scss +3 -4
  171. package/src/scss/components/height.scss +3 -0
  172. package/src/scss/components/icon.scss +2 -2
  173. package/src/scss/components/leader.scss +0 -1
  174. package/src/scss/components/lightbox.scss +0 -1
  175. package/src/scss/components/modal.scss +3 -7
  176. package/src/scss/components/navbar.scss +0 -7
  177. package/src/scss/components/progress.scss +14 -36
  178. package/src/scss/components/search.scss +1 -1
  179. package/src/scss/components/slider.scss +0 -3
  180. package/src/scss/components/slideshow.scss +0 -3
  181. package/src/scss/components/text.scss +16 -32
  182. package/src/scss/components/utility.scss +22 -0
  183. package/src/scss/mixins-theme.scss +1 -1
  184. package/src/scss/mixins.scss +1 -1
  185. package/src/scss/variables-theme.scss +9 -9
  186. package/src/scss/variables.scss +9 -9
  187. package/tests/align.html +10 -10
  188. package/tests/animation.html +2 -2
  189. package/tests/article.html +2 -2
  190. package/tests/base.html +3 -3
  191. package/tests/card.html +10 -10
  192. package/tests/column.html +3 -3
  193. package/tests/comment.html +9 -9
  194. package/tests/dotnav.html +3 -3
  195. package/tests/image.html +296 -64
  196. package/tests/images/image-type.avif +0 -0
  197. package/tests/images/image-type.jpeg +0 -0
  198. package/tests/images/image-type.webp +0 -0
  199. package/tests/index.html +8 -8
  200. package/tests/js/index.js +114 -85
  201. package/tests/lightbox.html +10 -10
  202. package/tests/marker.html +2 -2
  203. package/tests/modal.html +8 -9
  204. package/tests/navbar.html +2 -2
  205. package/tests/overlay.html +7 -7
  206. package/tests/parallax.html +14 -5
  207. package/tests/position.html +12 -12
  208. package/tests/slidenav.html +12 -12
  209. package/tests/slider.html +20 -20
  210. package/tests/sortable.html +1 -1
  211. package/tests/sticky-parallax.html +86 -98
  212. package/tests/sticky.html +56 -24
  213. package/tests/svg.html +6 -6
  214. package/tests/table.html +11 -11
  215. package/tests/thumbnav.html +12 -12
  216. package/tests/transition.html +30 -30
  217. package/tests/utility.html +33 -33
  218. package/tests/video.html +1 -1
  219. package/tests/width.html +1 -1
  220. package/src/js/mixin/flex-bug.js +0 -56
  221. package/src/js/util/promise.js +0 -191
  222. package/tests/images/animated.gif +0 -0
@@ -1,8 +1,21 @@
1
1
  import Container from '../mixin/container';
2
- import {$, append, apply, closest, css, parent, pointerEnter, pointerLeave, remove, startsWith, toFloat, Transition, trigger} from 'uikit-util';
2
+ import {
3
+ $,
4
+ append,
5
+ apply,
6
+ closest,
7
+ css,
8
+ parent,
9
+ pointerEnter,
10
+ pointerLeave,
11
+ remove,
12
+ startsWith,
13
+ toFloat,
14
+ Transition,
15
+ trigger,
16
+ } from 'uikit-util';
3
17
 
4
18
  export default {
5
-
6
19
  mixins: [Container],
7
20
 
8
21
  functional: true,
@@ -17,53 +30,53 @@ export default {
17
30
  pos: 'top-center',
18
31
  clsContainer: 'uk-notification',
19
32
  clsClose: 'uk-notification-close',
20
- clsMsg: 'uk-notification-message'
33
+ clsMsg: 'uk-notification-message',
21
34
  },
22
35
 
23
36
  install,
24
37
 
25
38
  computed: {
26
-
27
- marginProp({pos}) {
39
+ marginProp({ pos }) {
28
40
  return `margin${startsWith(pos, 'top') ? 'Top' : 'Bottom'}`;
29
41
  },
30
42
 
31
43
  startProps() {
32
- return {opacity: 0, [this.marginProp]: -this.$el.offsetHeight};
33
- }
34
-
44
+ return { opacity: 0, [this.marginProp]: -this.$el.offsetHeight };
45
+ },
35
46
  },
36
47
 
37
48
  created() {
38
-
39
- const container = $(`.${this.clsContainer}-${this.pos}`, this.container)
40
- || append(this.container, `<div class="${this.clsContainer} ${this.clsContainer}-${this.pos}" style="display: block"></div>`);
41
-
42
- this.$mount(append(container,
43
- `<div class="${this.clsMsg}${this.status ? ` ${this.clsMsg}-${this.status}` : ''}">
49
+ const container =
50
+ $(`.${this.clsContainer}-${this.pos}`, this.container) ||
51
+ append(
52
+ this.container,
53
+ `<div class="${this.clsContainer} ${this.clsContainer}-${this.pos}" style="display: block"></div>`
54
+ );
55
+
56
+ this.$mount(
57
+ append(
58
+ container,
59
+ `<div class="${this.clsMsg}${this.status ? ` ${this.clsMsg}-${this.status}` : ''}">
44
60
  <a href class="${this.clsClose}" data-uk-close></a>
45
61
  <div>${this.message}</div>
46
62
  </div>`
47
- ));
48
-
63
+ )
64
+ );
49
65
  },
50
66
 
51
- connected() {
52
-
67
+ async connected() {
53
68
  const margin = toFloat(css(this.$el, this.marginProp));
54
- Transition.start(
55
- css(this.$el, this.startProps),
56
- {opacity: 1, [this.marginProp]: margin}
57
- ).then(() => {
58
- if (this.timeout) {
59
- this.timer = setTimeout(this.close, this.timeout);
60
- }
69
+ await Transition.start(css(this.$el, this.startProps), {
70
+ opacity: 1,
71
+ [this.marginProp]: margin,
61
72
  });
62
73
 
74
+ if (this.timeout) {
75
+ this.timer = setTimeout(this.close, this.timeout);
76
+ }
63
77
  },
64
78
 
65
79
  events: {
66
-
67
80
  click(e) {
68
81
  if (closest(e.target, 'a[href="#"],a[href=""]')) {
69
82
  e.preventDefault();
@@ -81,45 +94,38 @@ export default {
81
94
  if (this.timeout) {
82
95
  this.timer = setTimeout(this.close, this.timeout);
83
96
  }
84
- }
85
-
97
+ },
86
98
  },
87
99
 
88
100
  methods: {
89
-
90
- close(immediate) {
91
-
92
- const removeFn = el => {
93
-
101
+ async close(immediate) {
102
+ const removeFn = (el) => {
94
103
  const container = parent(el);
95
104
 
96
105
  trigger(el, 'close', [this]);
97
106
  remove(el);
98
107
 
99
- if (container && !container.hasChildNodes()) {
108
+ if (!container?.hasChildNodes()) {
100
109
  remove(container);
101
110
  }
102
-
103
111
  };
104
112
 
105
113
  if (this.timer) {
106
114
  clearTimeout(this.timer);
107
115
  }
108
116
 
109
- if (immediate) {
110
- removeFn(this.$el);
111
- } else {
112
- Transition.start(this.$el, this.startProps).then(removeFn);
117
+ if (!immediate) {
118
+ await Transition.start(this.$el, this.startProps);
113
119
  }
114
- }
115
-
116
- }
117
120
 
121
+ removeFn(this.$el);
122
+ },
123
+ },
118
124
  };
119
125
 
120
126
  function install(UIkit) {
121
127
  UIkit.notification.closeAll = function (group, immediate) {
122
- apply(document.body, el => {
128
+ apply(document.body, (el) => {
123
129
  const notification = UIkit.getComponent(el, 'notification');
124
130
  if (notification && (!group || group === notification.group)) {
125
131
  notification.close(immediate);
@@ -1,8 +1,7 @@
1
1
  import Parallax from '../mixin/parallax';
2
- import {css, parent, query, scrolledOver, toPx} from 'uikit-util';
2
+ import { css, parent, query, scrolledOver, toPx } from 'uikit-util';
3
3
 
4
4
  export default {
5
-
6
5
  mixins: [Parallax],
7
6
 
8
7
  props: {
@@ -10,7 +9,7 @@ export default {
10
9
  viewport: Number, // Deprecated
11
10
  easing: Number,
12
11
  start: String,
13
- end: String
12
+ end: String,
14
13
  },
15
14
 
16
15
  data: {
@@ -18,32 +17,30 @@ export default {
18
17
  viewport: 1,
19
18
  easing: 1,
20
19
  start: 0,
21
- end: 0
20
+ end: 0,
22
21
  },
23
22
 
24
23
  computed: {
25
-
26
- target({target}, $el) {
27
- return getOffsetElement(target && query(target, $el) || $el);
24
+ target({ target }, $el) {
25
+ return getOffsetElement((target && query(target, $el)) || $el);
28
26
  },
29
27
 
30
- start({start}) {
31
- return parseCalc(start, this.target);
28
+ start({ start }) {
29
+ return toPx(start, 'height', this.target, true);
32
30
  },
33
31
 
34
- end({end, viewport}) {
35
- return parseCalc(
36
- end || (viewport = (1 - viewport) * 100) && `${viewport}vh+${viewport}%`,
37
- this.target
32
+ end({ end, viewport }) {
33
+ return toPx(
34
+ end || ((viewport = (1 - viewport) * 100) && `${viewport}vh+${viewport}%`),
35
+ 'height',
36
+ this.target,
37
+ true
38
38
  );
39
- }
40
-
39
+ },
41
40
  },
42
41
 
43
42
  update: {
44
-
45
- read({percent}, types) {
46
-
43
+ read({ percent }, types) {
47
44
  if (!types.has('scroll')) {
48
45
  percent = false;
49
46
  }
@@ -57,50 +54,28 @@ export default {
57
54
 
58
55
  return {
59
56
  percent,
60
- style: prev === percent ? false : this.getCss(percent)
57
+ style: prev === percent ? false : this.getCss(percent),
61
58
  };
62
59
  },
63
60
 
64
- write({style}) {
65
-
61
+ write({ style }) {
66
62
  if (!this.matchMedia) {
67
63
  this.reset();
68
64
  return;
69
65
  }
70
66
 
71
67
  style && css(this.$el, style);
72
-
73
68
  },
74
69
 
75
- events: ['scroll', 'resize']
76
- }
77
-
70
+ events: ['scroll', 'resize'],
71
+ },
78
72
  };
79
73
 
80
- const calcRe = /-?\d+(?:\.\d+)?(?:v[wh]|%|px)?/g;
81
- function parseCalc(calc, el) {
82
- let match;
83
- let result = 0;
84
- calc = calc.toString().replace(/\s/g, '');
85
- calcRe.lastIndex = 0;
86
- while ((match = calcRe.exec(calc)) !== null) {
87
- result += toPx(match[0], 'height', el, true);
88
- }
89
-
90
- return result;
91
- }
92
-
93
74
  function ease(percent, easing) {
94
- return easing >= 0
95
- ? Math.pow(percent, easing + 1)
96
- : 1 - Math.pow(1 - percent, -easing + 1);
75
+ return easing >= 0 ? Math.pow(percent, easing + 1) : 1 - Math.pow(1 - percent, -easing + 1);
97
76
  }
98
77
 
99
78
  // SVG elements do not inherit from HTMLElement
100
79
  function getOffsetElement(el) {
101
- return el
102
- ? 'offsetTop' in el
103
- ? el
104
- : getOffsetElement(parent(el))
105
- : document.documentElement;
80
+ return el ? ('offsetTop' in el ? el : getOffsetElement(parent(el))) : document.documentElement;
106
81
  }
@@ -1,24 +1,20 @@
1
1
  import Parallax from '../mixin/parallax';
2
- import {css, endsWith, fastdom, noop, query, Transition} from 'uikit-util';
2
+ import { css, endsWith, fastdom, noop, query, Transition } from 'uikit-util';
3
3
 
4
4
  export default {
5
-
6
5
  mixins: [Parallax],
7
6
 
8
7
  data: {
9
- selItem: '!li'
8
+ selItem: '!li',
10
9
  },
11
10
 
12
11
  computed: {
13
-
14
- item({selItem}, $el) {
12
+ item({ selItem }, $el) {
15
13
  return query(selItem, $el);
16
- }
17
-
14
+ },
18
15
  },
19
16
 
20
17
  events: [
21
-
22
18
  {
23
19
  name: 'itemin itemout',
24
20
 
@@ -28,18 +24,16 @@ export default {
28
24
  return this.item;
29
25
  },
30
26
 
31
- handler({type, detail: {percent, duration, timing, dir}}) {
32
-
27
+ handler({ type, detail: { percent, duration, timing, dir } }) {
33
28
  fastdom.read(() => {
34
29
  const propsFrom = this.getCss(getCurrentPercent(type, dir, percent));
35
- const propsTo = this.getCss(isIn(type) ? .5 : dir > 0 ? 1 : 0);
30
+ const propsTo = this.getCss(isIn(type) ? 0.5 : dir > 0 ? 1 : 0);
36
31
  fastdom.write(() => {
37
32
  css(this.$el, propsFrom);
38
33
  Transition.start(this.$el, propsTo, duration, timing).catch(noop);
39
34
  });
40
35
  });
41
-
42
- }
36
+ },
43
37
  },
44
38
 
45
39
  {
@@ -53,8 +47,7 @@ export default {
53
47
 
54
48
  handler() {
55
49
  Transition.cancel(this.$el);
56
- }
57
-
50
+ },
58
51
  },
59
52
 
60
53
  {
@@ -66,16 +59,14 @@ export default {
66
59
  return this.item;
67
60
  },
68
61
 
69
- handler({type, detail: {percent, dir}}) {
62
+ handler({ type, detail: { percent, dir } }) {
70
63
  fastdom.read(() => {
71
64
  const props = this.getCss(getCurrentPercent(type, dir, percent));
72
65
  fastdom.write(() => css(this.$el, props));
73
66
  });
74
- }
75
- }
76
-
77
- ]
78
-
67
+ },
68
+ },
69
+ ],
79
70
  };
80
71
 
81
72
  function isIn(type) {
@@ -83,8 +74,7 @@ function isIn(type) {
83
74
  }
84
75
 
85
76
  function getCurrentPercent(type, dir, percent) {
86
-
87
77
  percent /= 2;
88
78
 
89
- return isIn(type) ^ dir < 0 ? percent : 1 - percent;
79
+ return isIn(type) ^ (dir < 0) ? percent : 1 - percent;
90
80
  }
@@ -1,16 +1,31 @@
1
1
  import Class from '../mixin/class';
2
- import Slider, {speedUp} from '../mixin/slider';
2
+ import Slider, { speedUp } from '../mixin/slider';
3
3
  import SliderReactive from '../mixin/slider-reactive';
4
- import Transitioner, {getMax, getWidth} from './internal/slider-transitioner';
5
- import {$, addClass, children, css, data, dimensions, findIndex, includes, isEmpty, last, sortBy, toFloat, toggleClass, toNumber} from 'uikit-util';
4
+ import SliderPreload from './internal/slider-preload';
5
+ import Transitioner, { getMax, getWidth } from './internal/slider-transitioner';
6
+ import {
7
+ $,
8
+ addClass,
9
+ children,
10
+ css,
11
+ data,
12
+ dimensions,
13
+ findIndex,
14
+ includes,
15
+ isEmpty,
16
+ last,
17
+ sortBy,
18
+ toFloat,
19
+ toggleClass,
20
+ toNumber,
21
+ } from 'uikit-util';
6
22
 
7
23
  export default {
8
-
9
- mixins: [Class, Slider, SliderReactive],
24
+ mixins: [Class, Slider, SliderReactive, SliderPreload],
10
25
 
11
26
  props: {
12
27
  center: Boolean,
13
- sets: Boolean
28
+ sets: Boolean,
14
29
  },
15
30
 
16
31
  data: {
@@ -20,22 +35,24 @@ export default {
20
35
  selList: '.uk-slider-items',
21
36
  selNav: '.uk-slider-nav',
22
37
  clsContainer: 'uk-slider-container',
23
- Transitioner
38
+ Transitioner,
24
39
  },
25
40
 
26
41
  computed: {
27
-
28
42
  avgWidth() {
29
43
  return getWidth(this.list) / this.length;
30
44
  },
31
45
 
32
- finite({finite}) {
33
- return finite || Math.ceil(getWidth(this.list)) < dimensions(this.list).width + getMaxElWidth(this.list) + this.center;
46
+ finite({ finite }) {
47
+ return (
48
+ finite ||
49
+ Math.ceil(getWidth(this.list)) <
50
+ Math.floor(dimensions(this.list).width + getMaxElWidth(this.list) + this.center)
51
+ );
34
52
  },
35
53
 
36
54
  maxIndex() {
37
-
38
- if (!this.finite || this.center && !this.sets) {
55
+ if (!this.finite || (this.center && !this.sets)) {
39
56
  return this.length - 1;
40
57
  }
41
58
 
@@ -45,21 +62,18 @@ export default {
45
62
 
46
63
  let lft = 0;
47
64
  const max = getMax(this.list);
48
- const index = findIndex(this.slides, el => {
49
-
65
+ const index = findIndex(this.slides, (el) => {
50
66
  if (lft >= max) {
51
67
  return true;
52
68
  }
53
69
 
54
70
  lft += dimensions(el).width;
55
-
56
71
  });
57
72
 
58
73
  return ~index ? index : this.length - 1;
59
74
  },
60
75
 
61
- sets({sets}) {
62
-
76
+ sets({ sets }) {
63
77
  if (!sets) {
64
78
  return;
65
79
  }
@@ -71,47 +85,44 @@ export default {
71
85
  let slideLeft = 0;
72
86
 
73
87
  sets = sortBy(this.slides, 'offsetLeft').reduce((sets, slide, i) => {
74
-
75
88
  const slideWidth = dimensions(slide).width;
76
89
  const slideRight = slideLeft + slideWidth;
77
90
 
78
91
  if (slideRight > left) {
79
-
80
92
  if (!this.center && i > this.maxIndex) {
81
93
  i = this.maxIndex;
82
94
  }
83
95
 
84
96
  if (!includes(sets, i)) {
85
-
86
97
  const cmp = this.slides[i + 1];
87
- if (this.center && cmp && slideWidth < leftCenter - dimensions(cmp).width / 2) {
98
+ if (
99
+ this.center &&
100
+ cmp &&
101
+ slideWidth < leftCenter - dimensions(cmp).width / 2
102
+ ) {
88
103
  leftCenter -= slideWidth;
89
104
  } else {
90
105
  leftCenter = width;
91
106
  sets.push(i);
92
107
  left = slideLeft + width + (this.center ? slideWidth / 2 : 0);
93
108
  }
94
-
95
109
  }
96
110
  }
97
111
 
98
112
  slideLeft += slideWidth;
99
113
 
100
114
  return sets;
101
-
102
115
  }, []);
103
116
 
104
117
  return !isEmpty(sets) && sets;
105
-
106
118
  },
107
119
 
108
120
  transitionOptions() {
109
121
  return {
110
122
  center: this.center,
111
- list: this.list
123
+ list: this.list,
112
124
  };
113
- }
114
-
125
+ },
115
126
  },
116
127
 
117
128
  connected() {
@@ -119,14 +130,16 @@ export default {
119
130
  },
120
131
 
121
132
  update: {
122
-
123
133
  write() {
124
- this.navItems.forEach(el => {
134
+ for (const el of this.navItems) {
125
135
  const index = toNumber(data(el, this.attrItem));
126
136
  if (index !== false) {
127
- el.hidden = !this.maxIndex || index > this.maxIndex || this.sets && !includes(this.sets, index);
137
+ el.hidden =
138
+ !this.maxIndex ||
139
+ index > this.maxIndex ||
140
+ (this.sets && !includes(this.sets, index));
128
141
  }
129
- });
142
+ }
130
143
 
131
144
  if (this.length && !this.dragging && !this.stack.length) {
132
145
  this.reorder();
@@ -134,33 +147,40 @@ export default {
134
147
  }
135
148
 
136
149
  const actives = this._getTransitioner(this.index).getActives();
137
- this.slides.forEach(slide => toggleClass(slide, this.clsActive, includes(actives, slide)));
138
-
139
- if (this.clsActivated && (!this.sets || includes(this.sets, toFloat(this.index)))) {
140
- this.slides.forEach(slide => toggleClass(slide, this.clsActivated || '', includes(actives, slide)));
150
+ const activeClasses = [
151
+ this.clsActive,
152
+ ((!this.sets || includes(this.sets, toFloat(this.index))) && this.clsActivated) ||
153
+ '',
154
+ ];
155
+ for (const slide of this.slides) {
156
+ toggleClass(slide, activeClasses, includes(actives, slide));
141
157
  }
142
158
  },
143
159
 
144
- events: ['resize']
145
-
160
+ events: ['resize'],
146
161
  },
147
162
 
148
163
  events: {
149
-
150
164
  beforeitemshow(e) {
151
-
152
- if (!this.dragging && this.sets && this.stack.length < 2 && !includes(this.sets, this.index)) {
165
+ if (
166
+ !this.dragging &&
167
+ this.sets &&
168
+ this.stack.length < 2 &&
169
+ !includes(this.sets, this.index)
170
+ ) {
153
171
  this.index = this.getValidIndex();
154
172
  }
155
173
 
156
174
  const diff = Math.abs(
157
- this.index
158
- - this.prevIndex
159
- + (this.dir > 0 && this.index < this.prevIndex || this.dir < 0 && this.index > this.prevIndex ? (this.maxIndex + 1) * this.dir : 0)
175
+ this.index -
176
+ this.prevIndex +
177
+ ((this.dir > 0 && this.index < this.prevIndex) ||
178
+ (this.dir < 0 && this.index > this.prevIndex)
179
+ ? (this.maxIndex + 1) * this.dir
180
+ : 0)
160
181
  );
161
182
 
162
183
  if (!this.dragging && diff > 1) {
163
-
164
184
  for (let i = 0; i < diff; i++) {
165
185
  this.stack.splice(1, 0, this.dir > 0 ? 'next' : 'previous');
166
186
  }
@@ -169,25 +189,24 @@ export default {
169
189
  return;
170
190
  }
171
191
 
172
- const index = this.dir < 0 || !this.slides[this.prevIndex] ? this.index : this.prevIndex;
173
- this.duration = speedUp(this.avgWidth / this.velocity) * (dimensions(this.slides[index]).width / this.avgWidth);
192
+ const index =
193
+ this.dir < 0 || !this.slides[this.prevIndex] ? this.index : this.prevIndex;
194
+ this.duration =
195
+ speedUp(this.avgWidth / this.velocity) *
196
+ (dimensions(this.slides[index]).width / this.avgWidth);
174
197
 
175
198
  this.reorder();
176
-
177
199
  },
178
200
 
179
201
  itemshow() {
180
202
  if (~this.prevIndex) {
181
203
  addClass(this._getTransitioner().getItemIn(), this.clsActive);
182
204
  }
183
- }
184
-
205
+ },
185
206
  },
186
207
 
187
208
  methods: {
188
-
189
209
  reorder() {
190
-
191
210
  if (this.finite) {
192
211
  css(this.slides, 'order', '');
193
212
  return;
@@ -196,11 +215,10 @@ export default {
196
215
  const index = this.dir > 0 && this.slides[this.prevIndex] ? this.prevIndex : this.index;
197
216
 
198
217
  this.slides.forEach((slide, i) =>
199
- css(slide, 'order', this.dir > 0 && i < index
200
- ? 1
201
- : this.dir < 0 && i >= this.index
202
- ? -1
203
- : ''
218
+ css(
219
+ slide,
220
+ 'order',
221
+ this.dir > 0 && i < index ? 1 : this.dir < 0 && i >= this.index ? -1 : ''
204
222
  )
205
223
  );
206
224
 
@@ -219,11 +237,9 @@ export default {
219
237
  css(slide, 'order', slideIndex > index ? -2 : -1);
220
238
  width -= dimensions(slide).width;
221
239
  }
222
-
223
240
  },
224
241
 
225
242
  getValidIndex(index = this.index, prevIndex = this.prevIndex) {
226
-
227
243
  index = this.getIndex(index, prevIndex);
228
244
 
229
245
  if (!this.sets) {
@@ -233,23 +249,38 @@ export default {
233
249
  let prev;
234
250
 
235
251
  do {
236
-
237
252
  if (includes(this.sets, index)) {
238
253
  return index;
239
254
  }
240
255
 
241
256
  prev = index;
242
257
  index = this.getIndex(index + this.dir, prevIndex);
243
-
244
258
  } while (index !== prev);
245
259
 
246
260
  return index;
247
- }
248
-
249
- }
261
+ },
250
262
 
263
+ getAdjacentSlides() {
264
+ const { width } = dimensions(this.list);
265
+ const left = -width;
266
+ const right = width * 2;
267
+ const slideWidth = dimensions(this.slides[this.index]).width;
268
+ const slideLeft = this.center ? width / 2 - slideWidth / 2 : 0;
269
+ const slides = new Set();
270
+ for (const i of [-1, 1]) {
271
+ let currentLeft = slideLeft + (i > 0 ? slideWidth : 0);
272
+ let j = 0;
273
+ do {
274
+ const slide = this.slides[this.getIndex(this.index + i + j++ * i)];
275
+ currentLeft += dimensions(slide).width * i;
276
+ slides.add(slide);
277
+ } while (this.slides.length > j && currentLeft > left && currentLeft < right);
278
+ }
279
+ return Array.from(slides);
280
+ },
281
+ },
251
282
  };
252
283
 
253
284
  function getMaxElWidth(list) {
254
- return Math.max(0, ...children(list).map(el => dimensions(el).width));
285
+ return Math.max(0, ...children(list).map((el) => dimensions(el).width));
255
286
  }
@@ -1 +1 @@
1
- export {default} from './slider-parallax';
1
+ export { default } from './slider-parallax';