uikit 3.11.2-dev.4c11be04b → 3.11.2-dev.536e1a374

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 +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 +133 -201
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +133 -201
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +135 -207
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +135 -207
  25. package/dist/css/uikit.min.css +1 -1
  26. package/dist/js/components/countdown.js +66 -138
  27. package/dist/js/components/countdown.min.js +1 -1
  28. package/dist/js/components/filter.js +408 -439
  29. package/dist/js/components/filter.min.js +1 -1
  30. package/dist/js/components/lightbox-panel.js +1091 -1319
  31. package/dist/js/components/lightbox-panel.min.js +1 -1
  32. package/dist/js/components/lightbox.js +1137 -1396
  33. package/dist/js/components/lightbox.min.js +1 -1
  34. package/dist/js/components/notification.js +94 -114
  35. package/dist/js/components/notification.min.js +1 -1
  36. package/dist/js/components/parallax.js +347 -372
  37. package/dist/js/components/parallax.min.js +1 -1
  38. package/dist/js/components/slider-parallax.js +345 -360
  39. package/dist/js/components/slider-parallax.min.js +1 -1
  40. package/dist/js/components/slider.js +749 -843
  41. package/dist/js/components/slider.min.js +1 -1
  42. package/dist/js/components/slideshow-parallax.js +345 -360
  43. package/dist/js/components/slideshow-parallax.min.js +1 -1
  44. package/dist/js/components/slideshow.js +628 -798
  45. package/dist/js/components/slideshow.min.js +1 -1
  46. package/dist/js/components/sortable.js +587 -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 +156 -167
  51. package/dist/js/components/upload.min.js +1 -1
  52. package/dist/js/uikit-core.js +5325 -6495
  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 +8007 -9632
  57. package/dist/js/uikit.min.js +1 -1
  58. package/jsconfig.json +1 -1
  59. package/package.json +64 -60
  60. package/src/js/api/boot.js +25 -32
  61. package/src/js/api/component.js +15 -28
  62. package/src/js/api/global.js +6 -12
  63. package/src/js/api/hooks.js +14 -33
  64. package/src/js/api/instance.js +7 -15
  65. package/src/js/api/state.js +199 -187
  66. package/src/js/components/countdown.js +32 -85
  67. package/src/js/components/filter.js +70 -66
  68. package/src/js/components/index.js +13 -13
  69. package/src/js/components/internal/lightbox-animations.js +14 -25
  70. package/src/js/components/internal/slider-preload.js +9 -0
  71. package/src/js/components/internal/slider-transitioner.js +66 -45
  72. package/src/js/components/internal/slideshow-animations.js +46 -64
  73. package/src/js/components/lightbox-panel.js +107 -105
  74. package/src/js/components/lightbox.js +17 -39
  75. package/src/js/components/notification.js +49 -43
  76. package/src/js/components/parallax.js +21 -46
  77. package/src/js/components/slider-parallax.js +13 -23
  78. package/src/js/components/slider.js +117 -89
  79. package/src/js/components/slideshow-parallax.js +1 -1
  80. package/src/js/components/slideshow.js +15 -13
  81. package/src/js/components/sortable.js +126 -108
  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 +31 -35
  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 +197 -132
  109. package/src/js/core/svg.js +68 -83
  110. package/src/js/core/switcher.js +56 -47
  111. package/src/js/core/tab.js +7 -10
  112. package/src/js/core/toggle.js +69 -68
  113. package/src/js/core/video.js +22 -21
  114. package/src/js/mixin/animate.js +19 -20
  115. package/src/js/mixin/class.js +2 -4
  116. package/src/js/mixin/container.js +7 -11
  117. package/src/js/mixin/internal/animate-fade.js +73 -30
  118. package/src/js/mixin/internal/animate-slide.js +58 -41
  119. package/src/js/mixin/internal/slideshow-animations.js +7 -14
  120. package/src/js/mixin/internal/slideshow-transitioner.js +10 -17
  121. package/src/js/mixin/lazyload.js +20 -0
  122. package/src/js/mixin/media.js +5 -10
  123. package/src/js/mixin/modal.js +89 -66
  124. package/src/js/mixin/parallax.js +149 -107
  125. package/src/js/mixin/position.js +26 -20
  126. package/src/js/mixin/slider-autoplay.js +12 -21
  127. package/src/js/mixin/slider-drag.js +64 -65
  128. package/src/js/mixin/slider-nav.js +26 -35
  129. package/src/js/mixin/slider-reactive.js +2 -8
  130. package/src/js/mixin/slider.js +47 -60
  131. package/src/js/mixin/slideshow.js +12 -22
  132. package/src/js/mixin/swipe.js +72 -0
  133. package/src/js/mixin/togglable.js +89 -63
  134. package/src/js/uikit-core.js +2 -4
  135. package/src/js/uikit.js +2 -4
  136. package/src/js/util/ajax.js +25 -40
  137. package/src/js/util/animation.js +77 -75
  138. package/src/js/util/attr.js +17 -21
  139. package/src/js/util/class.js +14 -52
  140. package/src/js/util/dimensions.js +78 -49
  141. package/src/js/util/dom.js +37 -66
  142. package/src/js/util/env.js +7 -12
  143. package/src/js/util/event.js +60 -59
  144. package/src/js/util/fastdom.js +3 -8
  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 +81 -66
  156. package/src/less/components/base.less +10 -33
  157. package/src/less/components/flex.less +0 -9
  158. package/src/less/components/form-range.less +48 -95
  159. package/src/less/components/form.less +0 -1
  160. package/src/less/components/height.less +3 -0
  161. package/src/less/components/leader.less +0 -1
  162. package/src/less/components/lightbox.less +0 -1
  163. package/src/less/components/modal.less +3 -7
  164. package/src/less/components/navbar.less +0 -7
  165. package/src/less/components/progress.less +14 -36
  166. package/src/less/components/slider.less +0 -3
  167. package/src/less/components/slideshow.less +0 -3
  168. package/src/less/components/text.less +16 -32
  169. package/src/less/components/utility.less +25 -0
  170. package/src/scss/components/base.scss +10 -33
  171. package/src/scss/components/flex.scss +0 -9
  172. package/src/scss/components/form-range.scss +48 -95
  173. package/src/scss/components/form.scss +3 -4
  174. package/src/scss/components/height.scss +3 -0
  175. package/src/scss/components/icon.scss +2 -2
  176. package/src/scss/components/leader.scss +0 -1
  177. package/src/scss/components/lightbox.scss +0 -1
  178. package/src/scss/components/modal.scss +3 -7
  179. package/src/scss/components/navbar.scss +0 -7
  180. package/src/scss/components/progress.scss +14 -36
  181. package/src/scss/components/search.scss +1 -1
  182. package/src/scss/components/slider.scss +0 -3
  183. package/src/scss/components/slideshow.scss +0 -3
  184. package/src/scss/components/text.scss +16 -32
  185. package/src/scss/components/utility.scss +25 -0
  186. package/src/scss/mixins-theme.scss +1 -1
  187. package/src/scss/mixins.scss +1 -1
  188. package/src/scss/variables-theme.scss +9 -9
  189. package/src/scss/variables.scss +9 -9
  190. package/tests/align.html +10 -10
  191. package/tests/animation.html +2 -2
  192. package/tests/article.html +2 -2
  193. package/tests/base.html +3 -3
  194. package/tests/card.html +10 -10
  195. package/tests/column.html +3 -3
  196. package/tests/comment.html +9 -9
  197. package/tests/countdown.html +10 -8
  198. package/tests/dotnav.html +3 -3
  199. package/tests/image.html +296 -64
  200. package/tests/images/image-type.avif +0 -0
  201. package/tests/images/image-type.jpeg +0 -0
  202. package/tests/images/image-type.webp +0 -0
  203. package/tests/index.html +8 -8
  204. package/tests/js/index.js +114 -85
  205. package/tests/lightbox.html +10 -10
  206. package/tests/marker.html +2 -2
  207. package/tests/modal.html +8 -9
  208. package/tests/navbar.html +2 -2
  209. package/tests/overlay.html +7 -7
  210. package/tests/parallax.html +16 -7
  211. package/tests/position.html +12 -12
  212. package/tests/slidenav.html +12 -12
  213. package/tests/slider.html +20 -20
  214. package/tests/sortable.html +1 -1
  215. package/tests/sticky-parallax.html +87 -99
  216. package/tests/sticky.html +56 -24
  217. package/tests/svg.html +6 -6
  218. package/tests/table.html +11 -11
  219. package/tests/thumbnav.html +12 -12
  220. package/tests/transition.html +30 -30
  221. package/tests/utility.html +50 -33
  222. package/tests/video.html +1 -1
  223. package/tests/width.html +1 -1
  224. package/src/js/mixin/flex-bug.js +0 -56
  225. package/src/js/util/promise.js +0 -191
  226. package/tests/images/animated.gif +0 -0
@@ -1,8 +1,18 @@
1
- import {$$, css, filter, data as getData, isInView, once, Promise, removeClass, removeClasses, toggleClass, trigger} from 'uikit-util';
1
+ import {
2
+ $$,
3
+ css,
4
+ filter,
5
+ data as getData,
6
+ isInView,
7
+ once,
8
+ removeClass,
9
+ removeClasses,
10
+ toggleClass,
11
+ trigger,
12
+ } from 'uikit-util';
2
13
 
3
14
  const stateKey = '_ukScrollspy';
4
15
  export default {
5
-
6
16
  args: 'cls',
7
17
 
8
18
  props: {
@@ -12,7 +22,7 @@ export default {
12
22
  offsetTop: Number,
13
23
  offsetLeft: Number,
14
24
  repeat: Boolean,
15
- delay: Number
25
+ delay: Number,
16
26
  },
17
27
 
18
28
  data: () => ({
@@ -23,14 +33,12 @@ export default {
23
33
  offsetLeft: 0,
24
34
  repeat: false,
25
35
  delay: 0,
26
- inViewClass: 'uk-scrollspy-inview'
36
+ inViewClass: 'uk-scrollspy-inview',
27
37
  }),
28
38
 
29
39
  computed: {
30
-
31
40
  elements: {
32
-
33
- get({target}, $el) {
41
+ get({ target }, $el) {
34
42
  return target ? $$(target, $el) : [$el];
35
43
  },
36
44
 
@@ -40,25 +48,20 @@ export default {
40
48
  }
41
49
  },
42
50
 
43
- immediate: true
44
-
45
- }
46
-
51
+ immediate: true,
52
+ },
47
53
  },
48
54
 
49
55
  disconnected() {
50
- this.elements.forEach(el => {
56
+ for (const el of this.elements) {
51
57
  removeClass(el, this.inViewClass, el[stateKey] ? el[stateKey].cls : '');
52
58
  delete el[stateKey];
53
- });
59
+ }
54
60
  },
55
61
 
56
62
  update: [
57
-
58
63
  {
59
-
60
64
  read(data) {
61
-
62
65
  // Let child components be applied at least once first
63
66
  if (!data.update) {
64
67
  Promise.resolve().then(() => {
@@ -68,60 +71,43 @@ export default {
68
71
  return false;
69
72
  }
70
73
 
71
- this.elements.forEach(el => {
72
-
74
+ for (const el of this.elements) {
73
75
  if (!el[stateKey]) {
74
- el[stateKey] = {cls: getData(el, 'uk-scrollspy-class') || this.cls};
76
+ el[stateKey] = { cls: getData(el, 'uk-scrollspy-class') || this.cls };
75
77
  }
76
78
 
77
79
  el[stateKey].show = isInView(el, this.offsetTop, this.offsetLeft);
78
-
79
- });
80
-
80
+ }
81
81
  },
82
82
 
83
83
  write(data) {
84
-
85
- this.elements.forEach(el => {
86
-
84
+ for (const el of this.elements) {
87
85
  const state = el[stateKey];
88
86
 
89
87
  if (state.show && !state.inview && !state.queued) {
90
-
91
88
  state.queued = true;
92
89
 
93
- data.promise = (data.promise || Promise.resolve()).then(() =>
94
- new Promise(resolve =>
95
- setTimeout(resolve, this.delay)
96
- )
97
- ).then(() => {
98
- this.toggle(el, true);
99
- setTimeout(() => {
100
- state.queued = false;
101
- this.$emit();
102
- }, 300);
103
- });
104
-
90
+ data.promise = (data.promise || Promise.resolve())
91
+ .then(() => new Promise((resolve) => setTimeout(resolve, this.delay)))
92
+ .then(() => {
93
+ this.toggle(el, true);
94
+ setTimeout(() => {
95
+ state.queued = false;
96
+ this.$emit();
97
+ }, 300);
98
+ });
105
99
  } else if (!state.show && state.inview && !state.queued && this.repeat) {
106
-
107
100
  this.toggle(el, false);
108
-
109
101
  }
110
-
111
- });
112
-
102
+ }
113
103
  },
114
104
 
115
- events: ['scroll', 'resize']
116
-
117
- }
118
-
105
+ events: ['scroll', 'resize'],
106
+ },
119
107
  ],
120
108
 
121
109
  methods: {
122
-
123
110
  toggle(el, inview) {
124
-
125
111
  const state = el[stateKey];
126
112
 
127
113
  state.off && state.off();
@@ -142,9 +128,6 @@ export default {
142
128
  state.inview = inview;
143
129
 
144
130
  this.$update(el);
145
- }
146
-
147
- }
148
-
131
+ },
132
+ },
149
133
  };
150
-
@@ -1,12 +1,41 @@
1
1
  import Class from '../mixin/class';
2
2
  import Media from '../mixin/media';
3
- import {$, addClass, after, Animation, assign, css, dimensions, fastdom, height as getHeight, hasClass, isNumeric, isString, isVisible, noop, offset, offsetPosition, parent, query, remove, removeClass, replaceClass, scrollTop, toFloat, toggleClass, toPx, trigger, within} from 'uikit-util';
3
+ import {
4
+ $,
5
+ addClass,
6
+ after,
7
+ Animation,
8
+ clamp,
9
+ css,
10
+ dimensions,
11
+ fastdom,
12
+ height as getHeight,
13
+ offset as getOffset,
14
+ getScrollingElement,
15
+ hasClass,
16
+ isString,
17
+ isVisible,
18
+ noop,
19
+ offsetPosition,
20
+ parent,
21
+ query,
22
+ remove,
23
+ removeClass,
24
+ replaceClass,
25
+ scrollTop,
26
+ toFloat,
27
+ toggleClass,
28
+ toPx,
29
+ trigger,
30
+ within,
31
+ intersectRect,
32
+ } from 'uikit-util';
4
33
 
5
34
  export default {
6
-
7
35
  mixins: [Class, Media],
8
36
 
9
37
  props: {
38
+ position: String,
10
39
  top: null,
11
40
  bottom: Boolean,
12
41
  offset: String,
@@ -18,10 +47,11 @@ export default {
18
47
  selTarget: String,
19
48
  widthElement: Boolean,
20
49
  showOnUp: Boolean,
21
- targetOffset: Number
50
+ targetOffset: Number,
22
51
  },
23
52
 
24
53
  data: {
54
+ position: 'top',
25
55
  top: 0,
26
56
  bottom: false,
27
57
  offset: 0,
@@ -33,25 +63,19 @@ export default {
33
63
  selTarget: '',
34
64
  widthElement: false,
35
65
  showOnUp: false,
36
- targetOffset: false
66
+ targetOffset: false,
37
67
  },
38
68
 
39
69
  computed: {
40
-
41
- offset({offset}) {
42
- return toPx(offset);
43
- },
44
-
45
- selTarget({selTarget}, $el) {
46
- return selTarget && $(selTarget, $el) || $el;
70
+ selTarget({ selTarget }, $el) {
71
+ return (selTarget && $(selTarget, $el)) || $el;
47
72
  },
48
73
 
49
- widthElement({widthElement}, $el) {
74
+ widthElement({ widthElement }, $el) {
50
75
  return query(widthElement, $el) || this.placeholder;
51
76
  },
52
77
 
53
78
  isActive: {
54
-
55
79
  get() {
56
80
  return hasClass(this.selTarget, this.clsActive);
57
81
  },
@@ -64,20 +88,19 @@ export default {
64
88
  replaceClass(this.selTarget, this.clsActive, this.clsInactive);
65
89
  trigger(this.$el, 'inactive');
66
90
  }
67
- }
68
-
69
- }
70
-
91
+ },
92
+ },
71
93
  },
72
94
 
73
95
  connected() {
74
- this.placeholder = $('+ .uk-sticky-placeholder', this.$el) || $('<div class="uk-sticky-placeholder"></div>');
96
+ this.placeholder =
97
+ $('+ .uk-sticky-placeholder', this.$el) ||
98
+ $('<div class="uk-sticky-placeholder"></div>');
75
99
  this.isFixed = false;
76
100
  this.isActive = false;
77
101
  },
78
102
 
79
103
  disconnected() {
80
-
81
104
  if (this.isFixed) {
82
105
  this.hide();
83
106
  removeClass(this.selTarget, this.clsInactive);
@@ -89,91 +112,109 @@ export default {
89
112
  },
90
113
 
91
114
  events: [
92
-
93
115
  {
94
-
95
116
  name: 'load hashchange popstate',
96
117
 
97
118
  el() {
98
119
  return window;
99
120
  },
100
121
 
101
- handler() {
122
+ filter() {
123
+ return this.targetOffset !== false;
124
+ },
102
125
 
103
- if (!(this.targetOffset !== false && location.hash && window.pageYOffset > 0)) {
126
+ handler() {
127
+ if (!location.hash || scrollTop(window) === 0) {
104
128
  return;
105
129
  }
106
130
 
107
- const target = $(location.hash);
108
-
109
- if (target) {
110
- fastdom.read(() => {
111
-
112
- const {top} = offset(target);
113
- const elTop = offset(this.$el).top;
114
- const elHeight = this.$el.offsetHeight;
115
-
116
- if (this.isFixed && elTop + elHeight >= top && elTop <= top + target.offsetHeight) {
117
- scrollTop(window, top - elHeight - (isNumeric(this.targetOffset) ? this.targetOffset : 0) - this.offset);
118
- }
119
-
120
- });
121
- }
122
-
123
- }
124
-
125
- }
126
-
131
+ fastdom.read(() => {
132
+ const targetOffset = getOffset($(location.hash));
133
+ const elOffset = getOffset(this.$el);
134
+
135
+ if (this.isFixed && intersectRect(targetOffset, elOffset)) {
136
+ scrollTop(
137
+ window,
138
+ targetOffset.top -
139
+ elOffset.height -
140
+ toPx(this.targetOffset, 'height') -
141
+ toPx(this.offset, 'height')
142
+ );
143
+ }
144
+ });
145
+ },
146
+ },
127
147
  ],
128
148
 
129
149
  update: [
130
-
131
150
  {
132
-
133
- read({height}, types) {
134
-
151
+ read({ height, margin }, types) {
135
152
  this.inactive = !this.matchMedia || !isVisible(this.$el);
136
153
 
137
154
  if (this.inactive) {
138
155
  return false;
139
156
  }
140
157
 
141
- if (this.isActive && types.has('resize')) {
158
+ const hide = this.isActive && types.has('resize');
159
+ if (hide) {
160
+ css(this.selTarget, 'transition', '0s');
142
161
  this.hide();
143
- height = this.$el.offsetHeight;
144
- this.show();
145
162
  }
146
163
 
147
- height = this.isActive ? height : this.$el.offsetHeight;
164
+ if (!this.isActive) {
165
+ height = getOffset(this.$el).height;
166
+ margin = css(this.$el, 'margin');
167
+ }
148
168
 
149
- if (height + this.offset > getHeight(window)) {
150
- this.inactive = true;
151
- return false;
169
+ if (hide) {
170
+ this.show();
171
+ fastdom.write(() => css(this.selTarget, 'transition', ''));
152
172
  }
153
173
 
154
174
  const referenceElement = this.isFixed ? this.placeholder : this.$el;
155
- this.topOffset = offset(referenceElement).top;
156
- this.bottomOffset = this.topOffset + height;
157
- this.offsetParentTop = offset(referenceElement.offsetParent).top;
175
+ const windowHeight = getHeight(window);
158
176
 
159
- const bottom = parseProp('bottom', this);
177
+ let position = this.position;
178
+ if (position === 'auto' && height > windowHeight) {
179
+ position = 'bottom';
180
+ }
160
181
 
161
- this.top = Math.max(toFloat(parseProp('top', this)), this.topOffset) - this.offset;
162
- this.bottom = bottom && bottom - this.$el.offsetHeight;
163
- this.width = dimensions(isVisible(this.widthElement) ? this.widthElement : this.$el).width;
182
+ let offset = toPx(this.offset, 'height', referenceElement);
183
+ if (position === 'bottom') {
184
+ offset += windowHeight - height;
185
+ }
186
+
187
+ const overflow = Math.max(0, height + offset - windowHeight);
188
+ const topOffset = getOffset(referenceElement).top;
189
+ const offsetParentTop = getOffset(referenceElement.offsetParent).top;
190
+
191
+ const top = parseProp(this.top, this.$el, topOffset);
192
+ const bottom = parseProp(this.bottom, this.$el, topOffset + height, true);
193
+
194
+ const start = Math.max(top, topOffset) - offset;
195
+ const end = bottom
196
+ ? bottom - getOffset(this.$el).height + overflow - offset
197
+ : getScrollingElement(this.$el).scrollHeight - windowHeight;
164
198
 
165
199
  return {
200
+ start,
201
+ end,
202
+ offset,
203
+ overflow,
204
+ topOffset,
205
+ offsetParentTop,
166
206
  height,
167
- top: offsetPosition(this.placeholder)[0],
168
- margins: css(this.$el, ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'])
207
+ margin,
208
+ width: dimensions(isVisible(this.widthElement) ? this.widthElement : this.$el)
209
+ .width,
210
+ top: offsetPosition(referenceElement)[0],
169
211
  };
170
212
  },
171
213
 
172
- write({height, margins}) {
214
+ write({ height, margin }) {
215
+ const { placeholder } = this;
173
216
 
174
- const {placeholder} = this;
175
-
176
- css(placeholder, assign({height}, margins));
217
+ css(placeholder, { height, margin });
177
218
 
178
219
  if (!within(placeholder, document)) {
179
220
  after(this.$el, placeholder);
@@ -181,55 +222,82 @@ export default {
181
222
  }
182
223
 
183
224
  this.isActive = !!this.isActive; // force self-assign
184
-
185
225
  },
186
226
 
187
- events: ['resize']
188
-
227
+ events: ['resize'],
189
228
  },
190
229
 
191
230
  {
192
-
193
- read({scroll = 0}) {
194
-
195
- this.scroll = window.pageYOffset;
231
+ read({
232
+ scroll: prevScroll = 0,
233
+ dir: prevDir = 'down',
234
+ overflow,
235
+ overflowScroll = 0,
236
+ start,
237
+ end,
238
+ }) {
239
+ const scroll = scrollTop(window);
240
+ const dir = prevScroll <= scroll ? 'down' : 'up';
196
241
 
197
242
  return {
198
- dir: scroll <= this.scroll ? 'down' : 'up',
199
- scroll: this.scroll
243
+ dir,
244
+ prevDir,
245
+ scroll,
246
+ prevScroll,
247
+ overflowScroll: clamp(
248
+ overflowScroll + clamp(scroll, start, end) - clamp(prevScroll, start, end),
249
+ 0,
250
+ overflow
251
+ ),
200
252
  };
201
253
  },
202
254
 
203
255
  write(data, types) {
204
-
205
- const now = Date.now();
206
256
  const isScrollUpdate = types.has('scroll');
207
- const {initTimestamp = 0, dir, lastDir, lastScroll, scroll, top} = data;
208
-
209
- data.lastScroll = scroll;
257
+ const {
258
+ initTimestamp = 0,
259
+ dir,
260
+ prevDir,
261
+ scroll,
262
+ prevScroll = 0,
263
+ top,
264
+ start,
265
+ topOffset,
266
+ height,
267
+ } = data;
210
268
 
211
- if (scroll < 0 || scroll === lastScroll && isScrollUpdate || this.showOnUp && !isScrollUpdate && !this.isFixed) {
269
+ if (
270
+ scroll < 0 ||
271
+ (scroll === prevScroll && isScrollUpdate) ||
272
+ (this.showOnUp && !isScrollUpdate && !this.isFixed)
273
+ ) {
212
274
  return;
213
275
  }
214
276
 
215
- if (now - initTimestamp > 300 || dir !== lastDir) {
277
+ const now = Date.now();
278
+ if (now - initTimestamp > 300 || dir !== prevDir) {
216
279
  data.initScroll = scroll;
217
280
  data.initTimestamp = now;
218
281
  }
219
282
 
220
- data.lastDir = dir;
221
-
222
- if (this.showOnUp && !this.isFixed && Math.abs(data.initScroll - scroll) <= 30 && Math.abs(lastScroll - scroll) <= 10) {
283
+ if (
284
+ this.showOnUp &&
285
+ !this.isFixed &&
286
+ Math.abs(data.initScroll - scroll) <= 30 &&
287
+ Math.abs(prevScroll - scroll) <= 10
288
+ ) {
223
289
  return;
224
290
  }
225
291
 
226
- if (this.inactive
227
- || scroll < this.top
228
- || this.showOnUp && (scroll <= this.top || dir === 'down' && isScrollUpdate || dir === 'up' && !this.isFixed && scroll <= this.bottomOffset)
292
+ if (
293
+ this.inactive ||
294
+ scroll < start ||
295
+ (this.showOnUp &&
296
+ (scroll <= start ||
297
+ (dir === 'down' && isScrollUpdate) ||
298
+ (dir === 'up' && !this.isFixed && scroll <= topOffset + height)))
229
299
  ) {
230
-
231
300
  if (!this.isFixed) {
232
-
233
301
  if (Animation.inProgress(this.$el) && top > scroll) {
234
302
  Animation.cancel(this.$el);
235
303
  this.hide();
@@ -240,96 +308,93 @@ export default {
240
308
 
241
309
  this.isFixed = false;
242
310
 
243
- if (this.animation && scroll > this.topOffset) {
311
+ if (this.animation && scroll > topOffset) {
244
312
  Animation.cancel(this.$el);
245
313
  Animation.out(this.$el, this.animation).then(() => this.hide(), noop);
246
314
  } else {
247
315
  this.hide();
248
316
  }
249
-
250
317
  } else if (this.isFixed) {
251
-
252
318
  this.update();
253
-
254
- } else if (this.animation) {
255
-
319
+ } else if (this.animation && scroll > topOffset) {
256
320
  Animation.cancel(this.$el);
257
321
  this.show();
258
322
  Animation.in(this.$el, this.animation).catch(noop);
259
-
260
323
  } else {
261
324
  this.show();
262
325
  }
263
-
264
326
  },
265
327
 
266
- events: ['resize', 'scroll']
267
-
268
- }
269
-
328
+ events: ['resize', 'scroll'],
329
+ },
270
330
  ],
271
331
 
272
332
  methods: {
273
-
274
333
  show() {
275
-
276
334
  this.isFixed = true;
277
335
  this.update();
278
336
  this.placeholder.hidden = false;
279
-
280
337
  },
281
338
 
282
339
  hide() {
283
-
284
340
  this.isActive = false;
285
341
  removeClass(this.$el, this.clsFixed, this.clsBelow);
286
- css(this.$el, {position: '', top: '', width: ''});
342
+ css(this.$el, { position: '', top: '', width: '' });
287
343
  this.placeholder.hidden = true;
288
-
289
344
  },
290
345
 
291
346
  update() {
292
-
293
- const active = this.top !== 0 || this.scroll > this.top;
294
- let top = Math.max(0, this.offset);
347
+ let {
348
+ width,
349
+ scroll = 0,
350
+ overflow,
351
+ overflowScroll = 0,
352
+ start,
353
+ end,
354
+ offset,
355
+ topOffset,
356
+ height,
357
+ offsetParentTop,
358
+ } = this._data;
359
+ const active = start !== 0 || scroll > start;
295
360
  let position = 'fixed';
296
361
 
297
- if (isNumeric(this.bottom) && this.scroll > this.bottom - this.offset) {
298
- top = this.bottom - this.offsetParentTop;
362
+ if (scroll > end) {
363
+ offset += end - offsetParentTop;
299
364
  position = 'absolute';
300
365
  }
301
366
 
367
+ if (overflow) {
368
+ offset -= overflowScroll;
369
+ }
370
+
302
371
  css(this.$el, {
303
372
  position,
304
- top: `${top}px`,
305
- width: this.width
373
+ top: `${offset}px`,
374
+ width,
306
375
  });
307
376
 
308
377
  this.isActive = active;
309
- toggleClass(this.$el, this.clsBelow, this.scroll > this.bottomOffset);
378
+ toggleClass(this.$el, this.clsBelow, scroll > topOffset + height);
310
379
  addClass(this.$el, this.clsFixed);
311
-
312
- }
313
-
314
- }
315
-
380
+ },
381
+ },
316
382
  };
317
383
 
318
- function parseProp(prop, {$props, $el, [`${prop}Offset`]: propOffset}) {
319
-
320
- const value = $props[prop];
321
-
384
+ function parseProp(value, el, propOffset, padding) {
322
385
  if (!value) {
323
- return;
386
+ return 0;
324
387
  }
325
388
 
326
389
  if (isString(value) && value.match(/^-?\d/)) {
327
-
328
390
  return propOffset + toPx(value);
329
-
330
391
  } else {
331
-
332
- return offset(value === true ? parent($el) : query(value, $el)).bottom;
333
-
392
+ const refElement = value === true ? parent(el) : query(value, el);
393
+ return (
394
+ getOffset(refElement).bottom -
395
+ (padding && refElement && within(el, refElement)
396
+ ? toFloat(css(refElement, 'paddingBottom'))
397
+ : 0)
398
+ );
334
399
  }
335
400
  }