uikit 3.11.2-dev.f2970ffaa → 3.11.2-dev.f3ade19c4

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 (225) 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 +54 -18
  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 +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 +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 +155 -167
  51. package/dist/js/components/upload.min.js +1 -1
  52. package/dist/js/uikit-core.js +5326 -6526
  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 +8031 -9659
  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 +26 -52
  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 +52 -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 +39 -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 +17 -34
  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/dotnav.html +3 -3
  198. package/tests/image.html +296 -64
  199. package/tests/images/image-type.avif +0 -0
  200. package/tests/images/image-type.jpeg +0 -0
  201. package/tests/images/image-type.webp +0 -0
  202. package/tests/index.html +8 -8
  203. package/tests/js/index.js +114 -85
  204. package/tests/lightbox.html +10 -10
  205. package/tests/marker.html +2 -2
  206. package/tests/modal.html +8 -9
  207. package/tests/navbar.html +2 -2
  208. package/tests/overlay.html +7 -7
  209. package/tests/parallax.html +16 -7
  210. package/tests/position.html +12 -12
  211. package/tests/slidenav.html +12 -12
  212. package/tests/slider.html +20 -20
  213. package/tests/sortable.html +1 -1
  214. package/tests/sticky-parallax.html +87 -99
  215. package/tests/sticky.html +56 -24
  216. package/tests/svg.html +6 -6
  217. package/tests/table.html +11 -11
  218. package/tests/thumbnav.html +12 -12
  219. package/tests/transition.html +30 -30
  220. package/tests/utility.html +50 -33
  221. package/tests/video.html +1 -1
  222. package/tests/width.html +1 -1
  223. package/src/js/mixin/flex-bug.js +0 -56
  224. package/src/js/util/promise.js +0 -191
  225. package/tests/images/animated.gif +0 -0
@@ -1,7 +1,6 @@
1
- import {attr} from './attr';
2
- import {inBrowser} from './env';
3
- import {closest, index, matches, parent} from './filter';
4
- import {isDocument, isString, memoize, toNode, toNodes} from './lang';
1
+ import { attr } from './attr';
2
+ import { closest, index, matches, parent } from './filter';
3
+ import { isDocument, isString, memoize, toNode, toNodes } from './lang';
5
4
 
6
5
  export function query(selector, context) {
7
6
  return find(selector, getContext(selector, context));
@@ -11,12 +10,6 @@ export function queryAll(selector, context) {
11
10
  return findAll(selector, getContext(selector, context));
12
11
  }
13
12
 
14
- function getContext(selector, context = document) {
15
- return isString(selector) && isContextSelector(selector) || isDocument(context)
16
- ? context
17
- : context.ownerDocument;
18
- }
19
-
20
13
  export function find(selector, context) {
21
14
  return toNode(_query(selector, context, 'querySelector'));
22
15
  }
@@ -25,8 +18,18 @@ export function findAll(selector, context) {
25
18
  return toNodes(_query(selector, context, 'querySelectorAll'));
26
19
  }
27
20
 
28
- function _query(selector, context = document, queryFn) {
21
+ const contextSelectorRe = /(^|[^\\],)\s*[!>+~-]/;
22
+ const isContextSelector = memoize((selector) => selector.match(contextSelectorRe));
23
+
24
+ function getContext(selector, context = document) {
25
+ return (isString(selector) && isContextSelector(selector)) || isDocument(context)
26
+ ? context
27
+ : context.ownerDocument;
28
+ }
29
29
 
30
+ const contextSanitizeRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g;
31
+
32
+ function _query(selector, context = document, queryFn) {
30
33
  if (!selector || !isString(selector)) {
31
34
  return selector;
32
35
  }
@@ -34,63 +37,46 @@ function _query(selector, context = document, queryFn) {
34
37
  selector = selector.replace(contextSanitizeRe, '$1 *');
35
38
 
36
39
  if (isContextSelector(selector)) {
37
-
38
- selector = splitSelector(selector).map(selector => {
39
-
40
- let ctx = context;
41
-
42
- if (selector[0] === '!') {
43
-
44
- const selectors = selector.substr(1).trim().split(' ');
45
- ctx = closest(parent(context), selectors[0]);
46
- selector = selectors.slice(1).join(' ').trim();
47
-
48
- }
49
-
50
- if (selector[0] === '-') {
51
-
52
- const selectors = selector.substr(1).trim().split(' ');
53
- const prev = (ctx || context).previousElementSibling;
54
- ctx = matches(prev, selector.substr(1)) ? prev : null;
55
- selector = selectors.slice(1).join(' ');
56
-
57
- }
58
-
59
- if (!ctx) {
60
- return null;
61
- }
62
-
63
- return `${domPath(ctx)} ${selector}`;
64
-
65
- }).filter(Boolean).join(',');
40
+ selector = splitSelector(selector)
41
+ .map((selector) => {
42
+ let ctx = context;
43
+
44
+ if (selector[0] === '!') {
45
+ const selectors = selector.substr(1).trim().split(' ');
46
+ ctx = closest(parent(context), selectors[0]);
47
+ selector = selectors.slice(1).join(' ').trim();
48
+ }
49
+
50
+ if (selector[0] === '-') {
51
+ const selectors = selector.substr(1).trim().split(' ');
52
+ const prev = (ctx || context).previousElementSibling;
53
+ ctx = matches(prev, selector.substr(1)) ? prev : null;
54
+ selector = selectors.slice(1).join(' ');
55
+ }
56
+
57
+ if (!ctx) {
58
+ return null;
59
+ }
60
+
61
+ return `${domPath(ctx)} ${selector}`;
62
+ })
63
+ .filter(Boolean)
64
+ .join(',');
66
65
 
67
66
  context = document;
68
-
69
67
  }
70
68
 
71
69
  try {
72
-
73
70
  return context[queryFn](selector);
74
-
75
71
  } catch (e) {
76
-
77
72
  return null;
78
-
79
73
  }
80
-
81
74
  }
82
75
 
83
- const contextSelectorRe = /(^|[^\\],)\s*[!>+~-]/;
84
- const contextSanitizeRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g;
85
-
86
- const isContextSelector = memoize(selector => selector.match(contextSelectorRe));
87
-
88
76
  const selectorRe = /.*?[^\\](?:,|$)/g;
89
77
 
90
- const splitSelector = memoize(selector =>
91
- selector.match(selectorRe).map(selector =>
92
- selector.replace(/,$/, '').trim()
93
- )
78
+ const splitSelector = memoize((selector) =>
79
+ selector.match(selectorRe).map((selector) => selector.replace(/,$/, '').trim())
94
80
  );
95
81
 
96
82
  function domPath(element) {
@@ -101,7 +87,7 @@ function domPath(element) {
101
87
  names.unshift(`#${escape(id)}`);
102
88
  break;
103
89
  } else {
104
- let {tagName} = element;
90
+ let { tagName } = element;
105
91
  if (tagName !== 'HTML') {
106
92
  tagName += `:nth-child(${index(element) + 1})`;
107
93
  }
@@ -112,7 +98,6 @@ function domPath(element) {
112
98
  return names.join(' > ');
113
99
  }
114
100
 
115
- const escapeFn = inBrowser && window.CSS && CSS.escape || function (css) { return css.replace(/([^\x7f-\uFFFF\w-])/g, match => `\\${match}`); };
116
101
  export function escape(css) {
117
- return isString(css) ? escapeFn.call(null, css) : '';
102
+ return isString(css) ? CSS.escape(css) : '';
118
103
  }
@@ -1,7 +1,16 @@
1
- import {isIE} from './env';
2
- import {append, fragment, remove} from './dom';
3
- import {addClass} from './class';
4
- import {each, hyphenate, isArray, isNumber, isNumeric, isObject, isString, isUndefined, memoize, toNodes, toWindow} from './lang';
1
+ import {
2
+ each,
3
+ hyphenate,
4
+ isArray,
5
+ isNumber,
6
+ isNumeric,
7
+ isObject,
8
+ isString,
9
+ isUndefined,
10
+ memoize,
11
+ toNodes,
12
+ toWindow,
13
+ } from './lang';
5
14
 
6
15
  const cssNumber = {
7
16
  'animation-iteration-count': true,
@@ -11,22 +20,20 @@ const cssNumber = {
11
20
  'flex-shrink': true,
12
21
  'font-weight': true,
13
22
  'line-height': true,
14
- 'opacity': true,
15
- 'order': true,
16
- 'orphans': true,
23
+ opacity: true,
24
+ order: true,
25
+ orphans: true,
17
26
  'stroke-dasharray': true,
18
27
  'stroke-dashoffset': true,
19
- 'widows': true,
28
+ widows: true,
20
29
  'z-index': true,
21
- 'zoom': true
30
+ zoom: true,
22
31
  };
23
32
 
24
33
  export function css(element, property, value, priority = '') {
25
-
26
- return toNodes(element).map(element => {
27
-
34
+ const elements = toNodes(element);
35
+ for (const element of elements) {
28
36
  if (isString(property)) {
29
-
30
37
  property = propName(property);
31
38
 
32
39
  if (isUndefined(value)) {
@@ -34,27 +41,25 @@ export function css(element, property, value, priority = '') {
34
41
  } else if (!value && !isNumber(value)) {
35
42
  element.style.removeProperty(property);
36
43
  } else {
37
- element.style.setProperty(property, isNumeric(value) && !cssNumber[property] ? `${value}px` : value, priority);
44
+ element.style.setProperty(
45
+ property,
46
+ isNumeric(value) && !cssNumber[property] ? `${value}px` : value,
47
+ priority
48
+ );
38
49
  }
39
-
40
50
  } else if (isArray(property)) {
41
-
42
51
  const styles = getStyles(element);
43
-
44
- return property.reduce((props, property) => {
45
- props[property] = styles[propName(property)];
46
- return props;
47
- }, {});
48
-
52
+ const props = {};
53
+ for (const prop of property) {
54
+ props[prop] = styles[propName(prop)];
55
+ }
56
+ return props;
49
57
  } else if (isObject(property)) {
50
58
  priority = value;
51
59
  each(property, (value, property) => css(element, property, value, priority));
52
60
  }
53
-
54
- return element;
55
-
56
- })[0];
57
-
61
+ }
62
+ return elements[0];
58
63
  }
59
64
 
60
65
  function getStyles(element, pseudoElt) {
@@ -65,44 +70,29 @@ function getStyle(element, property, pseudoElt) {
65
70
  return getStyles(element, pseudoElt)[property];
66
71
  }
67
72
 
68
- const parseCssVar = memoize(name => {
69
- /* usage in css: .uk-name:before { content:"xyz" } */
70
-
71
- const element = append(document.documentElement, fragment('<div>'));
72
-
73
- addClass(element, `uk-${name}`);
74
-
75
- const value = getStyle(element, 'content', ':before');
76
-
77
- remove(element);
78
-
79
- return value;
80
- });
81
-
82
73
  const propertyRe = /^\s*(["'])?(.*?)\1\s*$/;
83
74
  export function getCssVar(name) {
84
- return (isIE
85
- ? parseCssVar(name)
86
- : getStyles(document.documentElement).getPropertyValue(`--uk-${name}`)
87
- ).replace(propertyRe, '$2');
75
+ return getStyles(document.documentElement)
76
+ .getPropertyValue(`--uk-${name}`)
77
+ .replace(propertyRe, '$2');
88
78
  }
89
79
 
90
80
  // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
91
- export const propName = memoize(name => vendorPropName(name));
81
+ export const propName = memoize((name) => vendorPropName(name));
92
82
 
93
83
  const cssPrefixes = ['webkit', 'moz', 'ms'];
94
84
 
95
85
  function vendorPropName(name) {
96
-
97
86
  name = hyphenate(name);
98
87
 
99
- const {style} = document.documentElement;
88
+ const { style } = document.documentElement;
100
89
 
101
90
  if (name in style) {
102
91
  return name;
103
92
  }
104
93
 
105
- let i = cssPrefixes.length, prefixedName;
94
+ let i = cssPrefixes.length,
95
+ prefixedName;
106
96
 
107
97
  while (i--) {
108
98
  prefixedName = `-${cssPrefixes[i]}-${name}`;
@@ -1,30 +1,39 @@
1
- import {css} from './style';
2
- import {Promise} from './promise';
3
- import {isVisible, parents} from './filter';
4
- import {offset, offsetPosition} from './dimensions';
5
- import {clamp, findIndex, intersectRect, isDocument, isUndefined, isWindow, toNode, toWindow} from './lang';
1
+ import { css } from './style';
2
+ import { isVisible, parents } from './filter';
3
+ import { offset, offsetPosition } from './dimensions';
4
+ import {
5
+ clamp,
6
+ findIndex,
7
+ intersectRect,
8
+ isDocument,
9
+ isUndefined,
10
+ isWindow,
11
+ toNode,
12
+ toWindow,
13
+ } from './lang';
6
14
 
7
15
  export function isInView(element, offsetTop = 0, offsetLeft = 0) {
8
-
9
16
  if (!isVisible(element)) {
10
17
  return false;
11
18
  }
12
19
 
13
- return intersectRect(...scrollParents(element).map(parent => {
14
-
15
- const {top, left, bottom, right} = offset(getViewport(parent));
16
-
17
- return {
18
- top: top - offsetTop,
19
- left: left - offsetLeft,
20
- bottom: bottom + offsetTop,
21
- right: right + offsetLeft
22
- };
23
- }).concat(offset(element)));
20
+ return intersectRect(
21
+ ...scrollParents(element)
22
+ .map((parent) => {
23
+ const { top, left, bottom, right } = offset(getViewport(parent));
24
+
25
+ return {
26
+ top: top - offsetTop,
27
+ left: left - offsetLeft,
28
+ bottom: bottom + offsetTop,
29
+ right: right + offsetLeft,
30
+ };
31
+ })
32
+ .concat(offset(element))
33
+ );
24
34
  }
25
35
 
26
36
  export function scrollTop(element, top) {
27
-
28
37
  if (isWindow(element) || isDocument(element)) {
29
38
  element = getScrollingElement(element);
30
39
  } else {
@@ -38,49 +47,44 @@ export function scrollTop(element, top) {
38
47
  }
39
48
  }
40
49
 
41
- export function scrollIntoView(element, {offset: offsetBy = 0} = {}) {
42
-
50
+ export function scrollIntoView(element, { offset: offsetBy = 0 } = {}) {
43
51
  const parents = isVisible(element) ? scrollParents(element) : [];
44
- return parents.reduce((fn, scrollElement, i) => {
45
-
46
- const {scrollTop, scrollHeight, offsetHeight} = scrollElement;
47
- const maxScroll = scrollHeight - getViewportClientHeight(scrollElement);
48
- const {height: elHeight, top: elTop} = offset(parents[i - 1] || element);
49
-
50
- let top = Math.ceil(
51
- elTop
52
- - offset(getViewport(scrollElement)).top
53
- - offsetBy
54
- + scrollTop
55
- );
56
-
57
- if (offsetBy > 0 && offsetHeight < elHeight + offsetBy) {
58
- top += offsetBy;
59
- } else {
60
- offsetBy = 0;
61
- }
62
-
63
- if (top > maxScroll) {
64
- offsetBy -= top - maxScroll;
65
- top = maxScroll;
66
- } else if (top < 0) {
67
- offsetBy -= top;
68
- top = 0;
69
- }
70
-
71
- return () => scrollTo(scrollElement, top - scrollTop).then(fn);
72
-
73
- }, () => Promise.resolve())();
52
+ return parents.reduce(
53
+ (fn, scrollElement, i) => {
54
+ const { scrollTop, scrollHeight, offsetHeight } = scrollElement;
55
+ const maxScroll = scrollHeight - getViewportClientHeight(scrollElement);
56
+ const { height: elHeight, top: elTop } = offset(parents[i - 1] || element);
57
+
58
+ let top = Math.ceil(
59
+ elTop - offset(getViewport(scrollElement)).top - offsetBy + scrollTop
60
+ );
61
+
62
+ if (offsetBy > 0 && offsetHeight < elHeight + offsetBy) {
63
+ top += offsetBy;
64
+ } else {
65
+ offsetBy = 0;
66
+ }
67
+
68
+ if (top > maxScroll) {
69
+ offsetBy -= top - maxScroll;
70
+ top = maxScroll;
71
+ } else if (top < 0) {
72
+ offsetBy -= top;
73
+ top = 0;
74
+ }
75
+
76
+ return () => scrollTo(scrollElement, top - scrollTop).then(fn);
77
+ },
78
+ () => Promise.resolve()
79
+ )();
74
80
 
75
81
  function scrollTo(element, top) {
76
- return new Promise(resolve => {
77
-
82
+ return new Promise((resolve) => {
78
83
  const scroll = element.scrollTop;
79
84
  const duration = getDuration(Math.abs(top));
80
85
  const start = Date.now();
81
86
 
82
87
  (function step() {
83
-
84
88
  const percent = ease(clamp((Date.now() - start) / duration));
85
89
 
86
90
  scrollTop(element, scroll + top * percent);
@@ -91,29 +95,26 @@ export function scrollIntoView(element, {offset: offsetBy = 0} = {}) {
91
95
  } else {
92
96
  requestAnimationFrame(step);
93
97
  }
94
-
95
98
  })();
96
99
  });
97
100
  }
98
101
 
99
102
  function getDuration(dist) {
100
- return 40 * Math.pow(dist, .375);
103
+ return 40 * Math.pow(dist, 0.375);
101
104
  }
102
105
 
103
106
  function ease(k) {
104
107
  return 0.5 * (1 - Math.cos(Math.PI * k));
105
108
  }
106
-
107
109
  }
108
110
 
109
111
  export function scrolledOver(element, startOffset = 0, endOffset = 0) {
110
-
111
112
  if (!isVisible(element)) {
112
113
  return 0;
113
114
  }
114
115
 
115
116
  const [scrollElement] = scrollParents(element, /auto|scroll/, true);
116
- const {scrollHeight, scrollTop} = scrollElement;
117
+ const { scrollHeight, scrollTop } = scrollElement;
117
118
  const viewportHeight = getViewportClientHeight(scrollElement);
118
119
  const maxScroll = scrollHeight - viewportHeight;
119
120
  const elementOffsetTop = offsetPosition(element)[0] - offsetPosition(scrollElement)[0];
@@ -130,14 +131,20 @@ export function scrollParents(element, overflowRe = /auto|scroll|hidden/, scroll
130
131
  let ancestors = parents(element).reverse();
131
132
  ancestors = ancestors.slice(ancestors.indexOf(scrollEl) + 1);
132
133
 
133
- const fixedIndex = findIndex(ancestors, el => css(el, 'position') === 'fixed');
134
+ const fixedIndex = findIndex(ancestors, (el) => css(el, 'position') === 'fixed');
134
135
  if (~fixedIndex) {
135
136
  ancestors = ancestors.slice(fixedIndex);
136
137
  }
137
138
 
138
- return [scrollEl].concat(ancestors.filter(parent =>
139
- overflowRe.test(css(parent, 'overflow')) && (!scrollable || parent.scrollHeight > getViewportClientHeight(parent)))
140
- ).reverse();
139
+ return [scrollEl]
140
+ .concat(
141
+ ancestors.filter(
142
+ (parent) =>
143
+ overflowRe.test(css(parent, 'overflow')) &&
144
+ (!scrollable || parent.scrollHeight > getViewportClientHeight(parent))
145
+ )
146
+ )
147
+ .reverse();
141
148
  }
142
149
 
143
150
  export function getViewport(scrollElement) {
@@ -146,10 +153,14 @@ export function getViewport(scrollElement) {
146
153
 
147
154
  // iOS 12 returns <body> as scrollingElement
148
155
  export function getViewportClientHeight(scrollElement) {
149
- return (scrollElement === getScrollingElement(scrollElement) ? document.documentElement : scrollElement).clientHeight;
156
+ return (
157
+ scrollElement === getScrollingElement(scrollElement)
158
+ ? document.documentElement
159
+ : scrollElement
160
+ ).clientHeight;
150
161
  }
151
162
 
152
163
  export function getScrollingElement(element) {
153
- const {document} = toWindow(element);
164
+ const { document } = toWindow(element);
154
165
  return document.scrollingElement || document.documentElement;
155
166
  }
@@ -91,7 +91,6 @@
91
91
 
92
92
  /*
93
93
  * 1. Set `font-size` to support `rem` units
94
- * Not using `font` property because a leading hyphen (e.g. -apple-system) causes the font to break in IE11 and Edge
95
94
  * 2. Prevent adjustments of font size after orientation changes in iOS.
96
95
  * 3. Style
97
96
  */
@@ -239,7 +238,7 @@ sub { bottom: -0.25em; }
239
238
  ========================================================================== */
240
239
 
241
240
  /*
242
- * Remove the gap between embedded content and the bottom of their containers.
241
+ * Remove the gap between the element and the bottom of its parent container.
243
242
  */
244
243
 
245
244
  audio,
@@ -250,14 +249,14 @@ svg,
250
249
  video { vertical-align: middle; }
251
250
 
252
251
  /*
253
- * 1. Add responsiveness.
254
- * 2. Auto-scale the height. Only needed if `height` attribute is present.
255
- * 3. Corrects responsive `max-width` behavior if padding and border are used.
256
- * 4. Exclude SVGs for IE11 because they don't preserve their aspect ratio.
252
+ * 1. Constrain the element to its parent width.
253
+ * 2. Preserve the intrinsic aspect ratio and auto-scale the height of an image if the `height` attribute is present.
254
+ * 3. Take border and padding into account.
257
255
  */
258
256
 
259
257
  canvas,
260
258
  img,
259
+ svg,
261
260
  video {
262
261
  /* 1 */
263
262
  max-width: 100%;
@@ -267,34 +266,17 @@ video {
267
266
  box-sizing: border-box;
268
267
  }
269
268
 
270
- /* 4 */
271
- @supports (display: block) {
272
-
273
- svg {
274
- max-width: 100%;
275
- height: auto;
276
- box-sizing: border-box;
277
- }
278
-
279
- }
280
-
281
- /*
282
- * Hide the overflow in IE.
283
- */
284
-
285
- svg:not(:root) { overflow: hidden; }
286
-
287
269
  /*
288
- * 1. Fix lazy loading images if parent element is set to `display: inline` and has `overflow: hidden`.
289
- * 2. Hide `alt` text for lazy loading images.
290
- * Note: Selector for background while loading img[data-src*='.jpg'][src*='data:image'] { background: grey; }
270
+ * Deprecated: only needed for `img` elements with `uk-img`
271
+ * 1. Hide `alt` text for lazy load images.
272
+ * 2. Fix lazy loading images if parent element is set to `display: inline` and has `overflow: hidden`.
291
273
  */
292
274
 
293
275
  img:not([src]) {
294
276
  /* 1 */
295
- min-width: 1px;
296
- /* 2 */
297
277
  visibility: hidden;
278
+ /* 2 */
279
+ min-width: 1px;
298
280
  }
299
281
 
300
282
  /*
@@ -589,11 +571,6 @@ template { display: none; }
589
571
  * Breakpoints
590
572
  */
591
573
 
592
- .uk-breakpoint-s::before { content: '@{breakpoint-small}'; }
593
- .uk-breakpoint-m::before { content: '@{breakpoint-medium}'; }
594
- .uk-breakpoint-l::before { content: '@{breakpoint-large}'; }
595
- .uk-breakpoint-xl::before { content: '@{breakpoint-xlarge}'; }
596
-
597
574
  :root {
598
575
  --uk-breakpoint-s: @breakpoint-small;
599
576
  --uk-breakpoint-m: @breakpoint-medium;
@@ -13,15 +13,6 @@
13
13
  .uk-flex { display: flex; }
14
14
  .uk-flex-inline { display: inline-flex; }
15
15
 
16
- /*
17
- * Remove pseudo elements created by micro clearfix as precaution
18
- */
19
-
20
- .uk-flex::before,
21
- .uk-flex::after,
22
- .uk-flex-inline::before,
23
- .uk-flex-inline::after { display: none; }
24
-
25
16
 
26
17
  /* Alignment
27
18
  ========================================================================== */