uikit 3.13.10 → 3.13.11-dev.1296bb84c

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 (100) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/dist/css/uikit-core-rtl.css +49 -8
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +49 -8
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +49 -6
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +49 -6
  9. package/dist/css/uikit.min.css +1 -1
  10. package/dist/js/components/countdown.js +1 -1
  11. package/dist/js/components/countdown.min.js +1 -1
  12. package/dist/js/components/filter.js +1 -1
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +7 -3
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +7 -3
  17. package/dist/js/components/lightbox.min.js +1 -1
  18. package/dist/js/components/notification.js +1 -1
  19. package/dist/js/components/notification.min.js +1 -1
  20. package/dist/js/components/parallax.js +21 -12
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +21 -12
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +2 -2
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +21 -12
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +1 -1
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +2 -2
  31. package/dist/js/components/sortable.min.js +1 -1
  32. package/dist/js/components/tooltip.js +62 -30
  33. package/dist/js/components/tooltip.min.js +1 -1
  34. package/dist/js/components/upload.js +1 -1
  35. package/dist/js/components/upload.min.js +1 -1
  36. package/dist/js/uikit-core.js +422 -299
  37. package/dist/js/uikit-core.min.js +1 -1
  38. package/dist/js/uikit-icons.js +1 -1
  39. package/dist/js/uikit-icons.min.js +1 -1
  40. package/dist/js/uikit.js +469 -307
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/components/slider.js +1 -1
  44. package/src/js/components/sortable.js +2 -3
  45. package/src/js/components/tooltip.js +38 -3
  46. package/src/js/core/cover.js +27 -14
  47. package/src/js/core/drop.js +40 -11
  48. package/src/js/core/height-match.js +1 -1
  49. package/src/js/core/margin.js +9 -2
  50. package/src/js/core/navbar.js +18 -6
  51. package/src/js/core/scrollspy-nav.js +6 -11
  52. package/src/js/core/sticky.js +55 -21
  53. package/src/js/mixin/media.js +12 -9
  54. package/src/js/mixin/modal.js +6 -2
  55. package/src/js/mixin/parallax.js +8 -3
  56. package/src/js/mixin/position.js +24 -24
  57. package/src/js/uikit-core.js +0 -4
  58. package/src/js/util/lang.js +34 -42
  59. package/src/js/util/position.js +180 -125
  60. package/src/js/util/viewport.js +42 -22
  61. package/src/less/components/drop.less +0 -1
  62. package/src/less/components/dropdown.less +11 -1
  63. package/src/less/components/icon.less +3 -0
  64. package/src/less/components/nav.less +23 -0
  65. package/src/less/components/navbar.less +26 -2
  66. package/src/less/components/search.less +2 -0
  67. package/src/less/components/sticky.less +8 -3
  68. package/src/less/components/utility.less +1 -0
  69. package/src/less/theme/dropdown.less +4 -0
  70. package/src/less/theme/nav.less +6 -0
  71. package/src/less/theme/navbar.less +4 -0
  72. package/src/less/theme/search.less +6 -0
  73. package/src/scss/components/drop.scss +0 -1
  74. package/src/scss/components/dropdown.scss +11 -1
  75. package/src/scss/components/icon.scss +3 -0
  76. package/src/scss/components/nav.scss +23 -0
  77. package/src/scss/components/navbar.scss +26 -2
  78. package/src/scss/components/search.scss +2 -0
  79. package/src/scss/components/sticky.scss +8 -3
  80. package/src/scss/components/utility.scss +1 -0
  81. package/src/scss/mixins-theme.scss +5 -0
  82. package/src/scss/mixins.scss +5 -0
  83. package/src/scss/theme/dropdown.scss +4 -0
  84. package/src/scss/theme/nav.scss +6 -0
  85. package/src/scss/theme/navbar.scss +4 -0
  86. package/src/scss/theme/search.scss +6 -0
  87. package/src/scss/variables-theme.scss +5 -1
  88. package/src/scss/variables.scss +5 -1
  89. package/tests/alert.html +1 -1
  90. package/tests/animation.html +216 -214
  91. package/tests/drop.html +154 -80
  92. package/tests/dropdown.html +16 -2
  93. package/tests/nav.html +27 -0
  94. package/tests/navbar.html +56 -5
  95. package/tests/parallax.html +5 -5
  96. package/tests/position.html +38 -39
  97. package/tests/sticky-navbar.html +6 -6
  98. package/tests/sticky-parallax.html +29 -13
  99. package/tests/sticky.html +300 -49
  100. package/src/js/core/core.js +0 -25
@@ -3,6 +3,7 @@ import {
3
3
  flipPosition,
4
4
  getCssVar,
5
5
  offset as getOffset,
6
+ includes,
6
7
  isNumeric,
7
8
  isRtl,
8
9
  positionAt,
@@ -20,49 +21,48 @@ export default {
20
21
  pos: `bottom-${isRtl ? 'right' : 'left'}`,
21
22
  flip: true,
22
23
  offset: false,
24
+ viewportPadding: 10,
23
25
  },
24
26
 
25
27
  connected() {
26
28
  this.pos = this.$props.pos.split('-').concat('center').slice(0, 2);
27
- this.dir = this.pos[0];
28
- this.align = this.pos[1];
29
+ this.axis = includes(['top', 'bottom'], this.pos[0]) ? 'y' : 'x';
29
30
  },
30
31
 
31
32
  methods: {
32
33
  positionAt(element, target, boundary) {
33
- const axis = this.getAxis();
34
- const dir = this.pos[0];
35
- const align = this.pos[1];
34
+ const [dir, align] = this.pos;
36
35
 
37
36
  let { offset } = this;
38
37
  if (!isNumeric(offset)) {
39
38
  const node = $(offset);
40
39
  offset = node
41
- ? getOffset(node)[axis === 'x' ? 'left' : 'top'] -
42
- getOffset(target)[axis === 'x' ? 'right' : 'bottom']
40
+ ? getOffset(node)[this.axis === 'x' ? 'left' : 'top'] -
41
+ getOffset(target)[this.axis === 'x' ? 'right' : 'bottom']
43
42
  : 0;
44
43
  }
45
44
  offset = toPx(offset) + toPx(getCssVar('position-offset', element));
45
+ offset = [includes(['left', 'top'], dir) ? -offset : +offset, 0];
46
46
 
47
- const { x, y } = positionAt(
48
- element,
49
- target,
50
- axis === 'x' ? `${flipPosition(dir)} ${align}` : `${align} ${flipPosition(dir)}`,
51
- axis === 'x' ? `${dir} ${align}` : `${align} ${dir}`,
52
- axis === 'x'
53
- ? `${dir === 'left' ? -offset : offset}`
54
- : ` ${dir === 'top' ? -offset : offset}`,
55
- null,
56
- this.flip,
57
- boundary
58
- ).target;
47
+ const attach = {
48
+ element: [flipPosition(dir), align],
49
+ target: [dir, align],
50
+ };
59
51
 
60
- this.dir = axis === 'x' ? x : y;
61
- this.align = axis === 'x' ? y : x;
62
- },
52
+ if (this.axis === 'y') {
53
+ for (const prop in attach) {
54
+ attach[prop] = attach[prop].reverse();
55
+ }
56
+ offset = offset.reverse();
57
+ }
63
58
 
64
- getAxis() {
65
- return this.dir === 'top' || this.dir === 'bottom' ? 'y' : 'x';
59
+ positionAt(element, target, {
60
+ attach,
61
+ offset,
62
+ boundary,
63
+ viewportPadding: this.viewportPadding,
64
+ flip: this.flip,
65
+ });
66
66
  },
67
67
  },
68
68
  };
@@ -1,5 +1,4 @@
1
1
  import UIkit from './api/index';
2
- import Core from './core/core';
3
2
  import boot from './api/boot';
4
3
  import * as components from './core/index';
5
4
  import { each } from 'uikit-util';
@@ -7,9 +6,6 @@ import { each } from 'uikit-util';
7
6
  // register components
8
7
  each(components, (component, name) => UIkit.component(name, component));
9
8
 
10
- // core functionality
11
- UIkit.use(Core);
12
-
13
9
  boot(UIkit);
14
10
 
15
11
  export default UIkit;
@@ -133,10 +133,6 @@ export function toWindow(element) {
133
133
  return document?.defaultView || window;
134
134
  }
135
135
 
136
- export function toMs(time) {
137
- return time ? (endsWith(time, 'ms') ? toFloat(time) : toFloat(time) * 1000) : 0;
138
- }
139
-
140
136
  export function isEqual(value, other) {
141
137
  return (
142
138
  value === other ||
@@ -204,48 +200,44 @@ export function pointInRect(point, rect) {
204
200
  );
205
201
  }
206
202
 
207
- export const Dimensions = {
208
- ratio(dimensions, prop, value) {
209
- const aProp = prop === 'width' ? 'height' : 'width';
210
-
211
- return {
212
- [aProp]: dimensions[prop]
213
- ? Math.round((value * dimensions[aProp]) / dimensions[prop])
214
- : dimensions[aProp],
215
- [prop]: value,
216
- };
217
- },
218
-
219
- contain(dimensions, maxDimensions) {
220
- dimensions = { ...dimensions };
221
-
222
- each(
223
- dimensions,
224
- (_, prop) =>
225
- (dimensions =
226
- dimensions[prop] > maxDimensions[prop]
227
- ? this.ratio(dimensions, prop, maxDimensions[prop])
228
- : dimensions)
229
- );
203
+ function ratio(dimensions, prop, value) {
204
+ const aProp = prop === 'width' ? 'height' : 'width';
230
205
 
231
- return dimensions;
232
- },
206
+ return {
207
+ [aProp]: dimensions[prop]
208
+ ? Math.round((value * dimensions[aProp]) / dimensions[prop])
209
+ : dimensions[aProp],
210
+ [prop]: value,
211
+ };
212
+ }
233
213
 
234
- cover(dimensions, maxDimensions) {
235
- dimensions = this.contain(dimensions, maxDimensions);
214
+ function contain(dimensions, maxDimensions) {
215
+ dimensions = { ...dimensions };
236
216
 
237
- each(
238
- dimensions,
239
- (_, prop) =>
240
- (dimensions =
241
- dimensions[prop] < maxDimensions[prop]
242
- ? this.ratio(dimensions, prop, maxDimensions[prop])
243
- : dimensions)
244
- );
217
+ for (const prop in dimensions) {
218
+ dimensions =
219
+ dimensions[prop] > maxDimensions[prop]
220
+ ? ratio(dimensions, prop, maxDimensions[prop])
221
+ : dimensions;
222
+ }
223
+
224
+ return dimensions;
225
+ }
226
+
227
+ function cover(dimensions, maxDimensions) {
228
+ dimensions = contain(dimensions, maxDimensions);
229
+
230
+ for (const prop in dimensions) {
231
+ dimensions =
232
+ dimensions[prop] < maxDimensions[prop]
233
+ ? ratio(dimensions, prop, maxDimensions[prop])
234
+ : dimensions;
235
+ }
236
+
237
+ return dimensions;
238
+ }
245
239
 
246
- return dimensions;
247
- },
248
- };
240
+ export const Dimensions = { ratio, contain, cover };
249
241
 
250
242
  export function getIndex(i, elements, current = 0, finite = false) {
251
243
  elements = toNodes(elements);
@@ -1,156 +1,211 @@
1
1
  import { offset } from './dimensions';
2
- import { each, endsWith, includes, toFloat } from './lang';
3
- import { getViewport, scrollParents } from './viewport';
4
-
5
- const dirs = {
6
- width: ['x', 'left', 'right'],
7
- height: ['y', 'top', 'bottom'],
8
- };
9
-
10
- export function positionAt(
11
- element,
12
- target,
13
- elAttach,
14
- targetAttach,
15
- elOffset,
16
- targetOffset,
17
- flip,
18
- boundary
19
- ) {
20
- elAttach = getPos(elAttach);
21
- targetAttach = getPos(targetAttach);
22
-
23
- const flipped = { element: elAttach, target: targetAttach };
24
-
25
- if (!element || !target) {
26
- return flipped;
2
+ import { clamp, includes, ucfirst } from './lang';
3
+ import { offsetViewport, scrollParents } from './viewport';
4
+
5
+ const dirs = [
6
+ ['width', 'x', 'left', 'right'],
7
+ ['height', 'y', 'top', 'bottom'],
8
+ ];
9
+
10
+ export function positionAt(element, target, options) {
11
+ options = {
12
+ attach: {
13
+ element: ['left', 'top'],
14
+ target: ['left', 'top'],
15
+ ...options.attach,
16
+ },
17
+ offset: [0, 0],
18
+ ...options,
19
+ };
20
+
21
+ const dim = options.flip
22
+ ? attachToWithFlip(element, target, options)
23
+ : attachTo(element, target, options);
24
+
25
+ offset(element, dim);
26
+ }
27
+
28
+ function attachTo(element, target, options) {
29
+ let { attach, offset: offsetBy } = {
30
+ attach: {
31
+ element: ['left', 'top'],
32
+ target: ['left', 'top'],
33
+ ...options.attach,
34
+ },
35
+ offset: [0, 0],
36
+ ...options,
37
+ };
38
+
39
+ const position = offset(element);
40
+ const targetOffset = offset(target);
41
+ for (const [i, [prop, dir, start, end]] of Object.entries(dirs)) {
42
+ position[start] = position[dir] =
43
+ targetOffset[start] +
44
+ moveBy(attach.target[i], end, targetOffset[prop]) -
45
+ moveBy(attach.element[i], end, position[prop]) +
46
+ +offsetBy[i];
47
+ position[end] = position[start] + position[prop];
27
48
  }
49
+ return position;
50
+ }
28
51
 
29
- const dim = offset(element);
52
+ function attachToWithFlip(element, target, options) {
53
+ const position = attachTo(element, target, options);
30
54
  const targetDim = offset(target);
31
- const position = targetDim;
32
55
 
33
- moveTo(position, elAttach, dim, -1);
34
- moveTo(position, targetAttach, targetDim, 1);
56
+ let {
57
+ flip,
58
+ attach: { element: elAttach, target: targetAttach },
59
+ offset: elOffset,
60
+ boundary,
61
+ viewport,
62
+ viewportPadding,
63
+ } = options;
64
+
65
+ let viewports = scrollParents(element);
66
+ if (boundary === target) {
67
+ viewports = viewports.filter((viewport) => viewport !== boundary);
68
+ }
69
+ const [scrollElement] = viewports;
70
+ viewports.push(viewport);
35
71
 
36
- elOffset = getOffsets(elOffset, dim.width, dim.height);
37
- targetOffset = getOffsets(targetOffset, targetDim.width, targetDim.height);
72
+ const offsetPosition = { ...position };
73
+ for (const [i, [prop, dir, start, end]] of Object.entries(dirs)) {
74
+ if (flip !== true && !includes(flip, dir)) {
75
+ continue;
76
+ }
38
77
 
39
- elOffset['x'] += targetOffset['x'];
40
- elOffset['y'] += targetOffset['y'];
78
+ const willFlip =
79
+ !intersectLine(position, targetDim, i) && intersectLine(position, targetDim, 1 - i);
41
80
 
42
- position.left += elOffset['x'];
43
- position.top += elOffset['y'];
81
+ viewport = getIntersectionArea(...viewports.filter(Boolean).map(offsetViewport));
44
82
 
45
- if (flip) {
46
- let boundaries = scrollParents(element).map(getViewport);
83
+ if (viewportPadding) {
84
+ viewport[start] += viewportPadding;
85
+ viewport[end] -= viewportPadding;
86
+ }
47
87
 
48
- if (boundary && !includes(boundaries, boundary)) {
49
- boundaries.unshift(boundary);
88
+ if (boundary && !willFlip && position[prop] <= offset(boundary)[prop]) {
89
+ viewport = getIntersectionArea(viewport, offset(boundary));
50
90
  }
51
91
 
52
- boundaries = boundaries.map((el) => offset(el));
92
+ const isInStartBoundary = position[start] >= viewport[start];
93
+ const isInEndBoundary = position[end] <= viewport[end];
53
94
 
54
- each(dirs, ([dir, align, alignFlip], prop) => {
55
- if (!(flip === true || includes(flip, dir))) {
56
- return;
95
+ if (isInStartBoundary && isInEndBoundary) {
96
+ continue;
97
+ }
98
+
99
+ let offsetBy;
100
+
101
+ // Flip
102
+ if (willFlip) {
103
+ if (
104
+ (elAttach[i] === end && isInStartBoundary) ||
105
+ (elAttach[i] === start && isInEndBoundary)
106
+ ) {
107
+ continue;
57
108
  }
58
109
 
59
- boundaries.some((boundary) => {
60
- const elemOffset =
61
- elAttach[dir] === align
62
- ? -dim[prop]
63
- : elAttach[dir] === alignFlip
64
- ? dim[prop]
65
- : 0;
66
-
67
- const targetOffset =
68
- targetAttach[dir] === align
69
- ? targetDim[prop]
70
- : targetAttach[dir] === alignFlip
71
- ? -targetDim[prop]
72
- : 0;
73
-
74
- if (
75
- position[align] < boundary[align] ||
76
- position[align] + dim[prop] > boundary[alignFlip]
77
- ) {
78
- const centerOffset = dim[prop] / 2;
79
- const centerTargetOffset =
80
- targetAttach[dir] === 'center' ? -targetDim[prop] / 2 : 0;
81
-
82
- return (
83
- (elAttach[dir] === 'center' &&
84
- (apply(centerOffset, centerTargetOffset) ||
85
- apply(-centerOffset, -centerTargetOffset))) ||
86
- apply(elemOffset, targetOffset)
87
- );
110
+ offsetBy =
111
+ (elAttach[i] === start
112
+ ? -position[prop]
113
+ : elAttach[i] === end
114
+ ? position[prop]
115
+ : 0) +
116
+ (targetAttach[i] === start
117
+ ? targetDim[prop]
118
+ : targetAttach[i] === end
119
+ ? -targetDim[prop]
120
+ : 0) -
121
+ elOffset[i] * 2;
122
+
123
+ if (
124
+ !isInScrollArea(
125
+ {
126
+ ...position,
127
+ [start]: position[start] + offsetBy,
128
+ [end]: position[end] + offsetBy,
129
+ },
130
+ scrollElement,
131
+ i
132
+ )
133
+ ) {
134
+ if (isInScrollArea(position, scrollElement, i)) {
135
+ continue;
136
+ }
137
+
138
+ if (options.recursion) {
139
+ return false;
88
140
  }
89
141
 
90
- function apply(elemOffset, targetOffset) {
91
- const newVal = toFloat(
92
- (position[align] + elemOffset + targetOffset - elOffset[dir] * 2).toFixed(4)
93
- );
94
-
95
- if (newVal >= boundary[align] && newVal + dim[prop] <= boundary[alignFlip]) {
96
- position[align] = newVal;
97
-
98
- for (const el of ['element', 'target']) {
99
- if (elemOffset) {
100
- flipped[el][dir] =
101
- flipped[el][dir] === dirs[prop][1]
102
- ? dirs[prop][2]
103
- : dirs[prop][1];
104
- }
105
- }
106
-
107
- return true;
108
- }
142
+ const newPos = attachToWithFlip(element, target, {
143
+ ...options,
144
+ attach: {
145
+ element: elAttach.map(flipDir).reverse(),
146
+ target: targetAttach.map(flipDir).reverse(),
147
+ },
148
+ offset: elOffset.reverse(),
149
+ flip: flip === true ? flip : [...flip, dirs[1 - i][1]],
150
+ recursion: true,
151
+ });
152
+
153
+ if (newPos && isInScrollArea(newPos, scrollElement, 1 - i)) {
154
+ return newPos;
109
155
  }
110
- });
111
- });
156
+ }
157
+
158
+ // Move
159
+ } else {
160
+ offsetBy =
161
+ clamp(
162
+ clamp(position[start], viewport[start], viewport[end] - position[prop]),
163
+ targetDim[start] - position[prop] + elOffset[i],
164
+ targetDim[end] - elOffset[i]
165
+ ) - position[start];
166
+ }
167
+
168
+ offsetPosition[start] = position[dir] = position[start] + offsetBy;
169
+ offsetPosition[end] += offsetBy;
112
170
  }
113
171
 
114
- offset(element, position);
172
+ return offsetPosition;
173
+ }
115
174
 
116
- return flipped;
175
+ function moveBy(start, end, dim) {
176
+ return start === 'center' ? dim / 2 : start === end ? dim : 0;
117
177
  }
118
178
 
119
- function moveTo(position, attach, dim, factor) {
120
- each(dirs, ([dir, align, alignFlip], prop) => {
121
- if (attach[dir] === alignFlip) {
122
- position[align] += dim[prop] * factor;
123
- } else if (attach[dir] === 'center') {
124
- position[align] += (dim[prop] * factor) / 2;
179
+ function getIntersectionArea(...rects) {
180
+ let area = {};
181
+ for (const rect of rects) {
182
+ for (const [, , start, end] of dirs) {
183
+ area[start] = Math.max(area[start] || 0, rect[start]);
184
+ area[end] = Math.min(...[area[end], rect[end]].filter(Boolean));
125
185
  }
126
- });
186
+ }
187
+ return area;
127
188
  }
128
189
 
129
- function getPos(pos) {
130
- const x = /left|center|right/;
131
- const y = /top|center|bottom/;
132
-
133
- pos = (pos || '').split(' ');
190
+ function isInScrollArea(position, scrollElement, dir) {
191
+ const viewport = offsetViewport(scrollElement);
192
+ const [prop, , start, end] = dirs[dir];
193
+ viewport[start] -= scrollElement[`scroll${ucfirst(start)}`];
194
+ viewport[end] = viewport[start] + scrollElement[`scroll${ucfirst(prop)}`];
134
195
 
135
- if (pos.length === 1) {
136
- pos = x.test(pos[0])
137
- ? pos.concat('center')
138
- : y.test(pos[0])
139
- ? ['center'].concat(pos)
140
- : ['center', 'center'];
141
- }
142
-
143
- return {
144
- x: x.test(pos[0]) ? pos[0] : 'center',
145
- y: y.test(pos[1]) ? pos[1] : 'center',
146
- };
196
+ return position[start] >= viewport[start] && position[end] <= viewport[end];
147
197
  }
148
198
 
149
- function getOffsets(offsets, width, height) {
150
- const [x, y] = (offsets || '').split(' ');
199
+ function intersectLine(dimA, dimB, dir) {
200
+ const [, , start, end] = dirs[dir];
201
+ return dimA[end] > dimB[start] && dimB[end] > dimA[start];
202
+ }
151
203
 
152
- return {
153
- x: x ? toFloat(x) * (endsWith(x, '%') ? width / 100 : 1) : 0,
154
- y: y ? toFloat(y) * (endsWith(y, '%') ? height / 100 : 1) : 0,
155
- };
204
+ function flipDir(prop) {
205
+ for (let i = 0; i < dirs.length; i++) {
206
+ const index = dirs[i].indexOf(prop);
207
+ if (~index) {
208
+ return dirs[1 - i][(index % 2) + 2];
209
+ }
210
+ }
156
211
  }
@@ -8,8 +8,10 @@ import {
8
8
  isDocument,
9
9
  isUndefined,
10
10
  isWindow,
11
+ toFloat,
11
12
  toNode,
12
13
  toWindow,
14
+ ucfirst,
13
15
  } from './lang';
14
16
 
15
17
  export function isInView(element, offsetTop = 0, offsetLeft = 0) {
@@ -20,7 +22,7 @@ export function isInView(element, offsetTop = 0, offsetLeft = 0) {
20
22
  return intersectRect(
21
23
  ...scrollParents(element)
22
24
  .map((parent) => {
23
- const { top, left, bottom, right } = offset(getViewport(parent));
25
+ const { top, left, bottom, right } = offsetViewport(parent);
24
26
 
25
27
  return {
26
28
  top: top - offsetTop,
@@ -35,7 +37,7 @@ export function isInView(element, offsetTop = 0, offsetLeft = 0) {
35
37
 
36
38
  export function scrollTop(element, top) {
37
39
  if (isWindow(element) || isDocument(element)) {
38
- element = getScrollingElement(element);
40
+ element = scrollingElement(element);
39
41
  } else {
40
42
  element = toNode(element);
41
43
  }
@@ -52,12 +54,13 @@ export function scrollIntoView(element, { offset: offsetBy = 0 } = {}) {
52
54
  return parents.reduce(
53
55
  (fn, scrollElement, i) => {
54
56
  const { scrollTop, scrollHeight, offsetHeight } = scrollElement;
55
- const maxScroll = scrollHeight - getViewportClientHeight(scrollElement);
56
- const { height: elHeight, top: elTop } = offset(parents[i - 1] || element);
57
+ const viewport = offsetViewport(scrollElement);
58
+ const maxScroll = scrollHeight - viewport.height;
59
+ const { height: elHeight, top: elTop } = parents[i - 1]
60
+ ? offsetViewport(parents[i - 1])
61
+ : offset(element);
57
62
 
58
- let top = Math.ceil(
59
- elTop - offset(getViewport(scrollElement)).top - offsetBy + scrollTop
60
- );
63
+ let top = Math.ceil(elTop - viewport.top - offsetBy + scrollTop);
61
64
 
62
65
  if (offsetBy > 0 && offsetHeight < elHeight + offsetBy) {
63
66
  top += offsetBy;
@@ -115,7 +118,7 @@ export function scrolledOver(element, startOffset = 0, endOffset = 0) {
115
118
 
116
119
  const [scrollElement] = scrollParents(element, /auto|scroll/, true);
117
120
  const { scrollHeight, scrollTop } = scrollElement;
118
- const viewportHeight = getViewportClientHeight(scrollElement);
121
+ const { height: viewportHeight } = offsetViewport(scrollElement);
119
122
  const maxScroll = scrollHeight - viewportHeight;
120
123
  const elementOffsetTop = offsetPosition(element)[0] - offsetPosition(scrollElement)[0];
121
124
 
@@ -126,7 +129,7 @@ export function scrolledOver(element, startOffset = 0, endOffset = 0) {
126
129
  }
127
130
 
128
131
  export function scrollParents(element, overflowRe = /auto|scroll|hidden/, scrollable = false) {
129
- const scrollEl = getScrollingElement(element);
132
+ const scrollEl = scrollingElement(element);
130
133
 
131
134
  let ancestors = parents(element).reverse();
132
135
  ancestors = ancestors.slice(ancestors.indexOf(scrollEl) + 1);
@@ -141,26 +144,43 @@ export function scrollParents(element, overflowRe = /auto|scroll|hidden/, scroll
141
144
  ancestors.filter(
142
145
  (parent) =>
143
146
  overflowRe.test(css(parent, 'overflow')) &&
144
- (!scrollable || parent.scrollHeight > getViewportClientHeight(parent))
147
+ (!scrollable || parent.scrollHeight > offsetViewport(parent).height)
145
148
  )
146
149
  )
147
150
  .reverse();
148
151
  }
149
152
 
150
- export function getViewport(scrollElement) {
151
- return scrollElement === getScrollingElement(scrollElement) ? window : scrollElement;
153
+ export function offsetViewport(scrollElement) {
154
+ let viewportElement = getViewport(scrollElement);
155
+
156
+ // iOS 12 returns <body> as scrollingElement
157
+ if (viewportElement === scrollingElement(viewportElement)) {
158
+ viewportElement = document.documentElement;
159
+ }
160
+
161
+ let rect = offset(viewportElement);
162
+ for (let [prop, dir, start, end] of [
163
+ ['width', 'x', 'left', 'right'],
164
+ ['height', 'y', 'top', 'bottom'],
165
+ ]) {
166
+ if (!isWindow(getViewport(viewportElement))) {
167
+ rect[start] += toFloat(css(viewportElement, `border${ucfirst(start)}Width`));
168
+ }
169
+ rect[prop] = rect[dir] = (
170
+ isWindow(viewportElement) ? scrollingElement(viewportElement) : viewportElement
171
+ )[`client${ucfirst(prop)}`];
172
+ rect[end] = rect[prop] + rect[start];
173
+ }
174
+ return rect;
152
175
  }
153
176
 
154
- // iOS 12 returns <body> as scrollingElement
155
- export function getViewportClientHeight(scrollElement) {
156
- return (
157
- scrollElement === getScrollingElement(scrollElement)
158
- ? document.documentElement
159
- : scrollElement
160
- ).clientHeight;
177
+ function scrollingElement(element) {
178
+ const {
179
+ document: { scrollingElement },
180
+ } = toWindow(element);
181
+ return scrollingElement;
161
182
  }
162
183
 
163
- export function getScrollingElement(element) {
164
- const { document } = toWindow(element);
165
- return document.scrollingElement || document.documentElement;
184
+ function getViewport(scrollElement) {
185
+ return scrollElement === scrollingElement(scrollElement) ? window : scrollElement;
166
186
  }
@@ -45,7 +45,6 @@
45
45
  /* 3 */
46
46
  box-sizing: border-box;
47
47
  width: @drop-width;
48
- max-width: 100vw;
49
48
  }
50
49
 
51
50
  /* Show */