uikit 3.14.3 → 3.14.4-dev.008162cc3
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.
- package/CHANGELOG.md +28 -0
- package/dist/css/uikit-core-rtl.css +111 -35
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +111 -35
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +114 -50
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +114 -50
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +1 -1
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +1 -1
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +210 -32
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +210 -32
- package/dist/js/components/lightbox.min.js +1 -1
- package/dist/js/components/notification.js +1 -1
- package/dist/js/components/notification.min.js +1 -1
- package/dist/js/components/parallax.js +1 -1
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +1 -1
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +22 -7
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +1 -1
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +22 -7
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +3 -3
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +142 -34
- package/dist/js/components/tooltip.min.js +1 -1
- package/dist/js/components/upload.js +1 -1
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +818 -636
- package/dist/js/uikit-core.min.js +1 -1
- package/dist/js/uikit-icons.js +1 -1
- package/dist/js/uikit-icons.min.js +1 -1
- package/dist/js/uikit.js +1632 -1435
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/components/sortable.js +2 -3
- package/src/js/core/accordion.js +3 -3
- package/src/js/core/alert.js +1 -1
- package/src/js/core/drop.js +47 -20
- package/src/js/core/height-viewport.js +18 -9
- package/src/js/core/navbar.js +11 -9
- package/src/js/core/offcanvas.js +1 -47
- package/src/js/core/sticky.js +8 -9
- package/src/js/core/switcher.js +1 -1
- package/src/js/mixin/modal.js +90 -4
- package/src/js/mixin/position.js +52 -13
- package/src/js/mixin/slider-drag.js +20 -8
- package/src/js/mixin/togglable.js +105 -24
- package/src/js/util/animation.js +1 -0
- package/src/js/util/dimensions.js +6 -6
- package/src/js/util/position.js +2 -0
- package/src/js/util/viewport.js +23 -37
- package/src/less/components/drop.less +19 -5
- package/src/less/components/dropdown.less +21 -5
- package/src/less/components/margin.less +13 -14
- package/src/less/components/modal.less +19 -4
- package/src/less/components/nav.less +23 -5
- package/src/less/components/navbar.less +56 -26
- package/src/less/components/offcanvas.less +21 -21
- package/src/less/components/position.less +1 -1
- package/src/less/components/utility.less +12 -4
- package/src/less/theme/dropdown.less +11 -0
- package/src/less/theme/nav.less +3 -7
- package/src/less/theme/navbar.less +12 -12
- package/src/scss/components/drop.scss +19 -5
- package/src/scss/components/dropdown.scss +21 -5
- package/src/scss/components/margin.scss +13 -14
- package/src/scss/components/modal.scss +19 -4
- package/src/scss/components/nav.scss +23 -5
- package/src/scss/components/navbar.scss +45 -15
- package/src/scss/components/offcanvas.scss +21 -21
- package/src/scss/components/position.scss +1 -1
- package/src/scss/components/utility.scss +12 -4
- package/src/scss/mixins-theme.scss +9 -13
- package/src/scss/mixins.scss +2 -0
- package/src/scss/theme/dropdown.scss +8 -0
- package/src/scss/theme/nav.scss +3 -7
- package/src/scss/theme/navbar.scss +9 -0
- package/src/scss/variables-theme.scss +35 -14
- package/src/scss/variables.scss +33 -13
- package/tests/drop.html +151 -2
- package/tests/dropdown.html +228 -13
- package/tests/height-viewport.html +62 -0
- package/tests/navbar.html +2166 -1085
- package/tests/offcanvas.html +8 -8
- package/tests/sticky-navbar.html +132 -0
package/src/js/mixin/position.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
dimensions,
|
|
4
|
+
flipPosition,
|
|
5
|
+
getCssVar,
|
|
6
|
+
includes,
|
|
7
|
+
isRtl,
|
|
8
|
+
positionAt,
|
|
9
|
+
scrollParents,
|
|
10
|
+
toPx,
|
|
11
|
+
} from 'uikit-util';
|
|
2
12
|
|
|
3
13
|
export default {
|
|
4
14
|
props: {
|
|
@@ -15,23 +25,17 @@ export default {
|
|
|
15
25
|
|
|
16
26
|
connected() {
|
|
17
27
|
this.pos = this.$props.pos.split('-').concat('center').slice(0, 2);
|
|
18
|
-
this.
|
|
28
|
+
[this.dir, this.align] = this.pos;
|
|
29
|
+
this.axis = includes(['top', 'bottom'], this.dir) ? 'y' : 'x';
|
|
19
30
|
},
|
|
20
31
|
|
|
21
32
|
methods: {
|
|
22
33
|
positionAt(element, target, boundary) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let offset = toPx(
|
|
26
|
-
this.offset === false ? getCssVar('position-offset', element) : this.offset,
|
|
27
|
-
this.axis === 'x' ? 'width' : 'height',
|
|
28
|
-
element
|
|
29
|
-
);
|
|
30
|
-
offset = [includes(['left', 'top'], dir) ? -offset : +offset, 0];
|
|
34
|
+
let offset = [this.getPositionOffset(element), this.getShiftOffset(element)];
|
|
31
35
|
|
|
32
36
|
const attach = {
|
|
33
|
-
element: [flipPosition(dir), align],
|
|
34
|
-
target: [dir, align],
|
|
37
|
+
element: [flipPosition(this.dir), this.align],
|
|
38
|
+
target: [this.dir, this.align],
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
if (this.axis === 'y') {
|
|
@@ -41,13 +45,48 @@ export default {
|
|
|
41
45
|
offset = offset.reverse();
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
const [scrollElement] = scrollParents(element, /auto|scroll/);
|
|
49
|
+
const { scrollTop, scrollLeft } = scrollElement;
|
|
50
|
+
|
|
51
|
+
// Ensure none positioned element does not generate scrollbars
|
|
52
|
+
const elDim = dimensions(element);
|
|
53
|
+
css(element, { top: -elDim.height, left: -elDim.width });
|
|
54
|
+
|
|
44
55
|
positionAt(element, target, {
|
|
45
56
|
attach,
|
|
46
57
|
offset,
|
|
47
58
|
boundary,
|
|
48
59
|
flip: this.flip,
|
|
49
|
-
viewportOffset:
|
|
60
|
+
viewportOffset: this.getViewportOffset(element),
|
|
50
61
|
});
|
|
62
|
+
|
|
63
|
+
// Restore scroll position
|
|
64
|
+
scrollElement.scrollTop = scrollTop;
|
|
65
|
+
scrollElement.scrollLeft = scrollLeft;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
getPositionOffset(element) {
|
|
69
|
+
return (
|
|
70
|
+
toPx(
|
|
71
|
+
this.offset === false ? getCssVar('position-offset', element) : this.offset,
|
|
72
|
+
this.axis === 'x' ? 'width' : 'height',
|
|
73
|
+
element
|
|
74
|
+
) * (includes(['left', 'top'], this.dir) ? -1 : 1)
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
getShiftOffset(element) {
|
|
79
|
+
return includes(['center', 'justify', 'stretch'], this.align)
|
|
80
|
+
? 0
|
|
81
|
+
: toPx(
|
|
82
|
+
getCssVar('position-shift-offset', element),
|
|
83
|
+
this.axis === 'y' ? 'width' : 'height',
|
|
84
|
+
element
|
|
85
|
+
) * (includes(['left', 'top'], this.align) ? 1 : -1);
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
getViewportOffset(element) {
|
|
89
|
+
return toPx(getCssVar('position-viewport-offset', element));
|
|
51
90
|
},
|
|
52
91
|
},
|
|
53
92
|
};
|
|
@@ -5,16 +5,18 @@ import {
|
|
|
5
5
|
includes,
|
|
6
6
|
isRtl,
|
|
7
7
|
isTouch,
|
|
8
|
+
noop,
|
|
8
9
|
off,
|
|
9
10
|
on,
|
|
10
|
-
pointerCancel,
|
|
11
|
-
pointerDown,
|
|
12
|
-
pointerMove,
|
|
13
|
-
pointerUp,
|
|
14
11
|
selInput,
|
|
15
12
|
trigger,
|
|
16
13
|
} from 'uikit-util';
|
|
17
14
|
|
|
15
|
+
const pointerOptions = { passive: false, capture: true };
|
|
16
|
+
const pointerDown = 'touchstart mousedown';
|
|
17
|
+
const pointerMove = 'touchmove mousemove';
|
|
18
|
+
const pointerUp = 'touchend touchcancel mouseup click input';
|
|
19
|
+
|
|
18
20
|
export default {
|
|
19
21
|
props: {
|
|
20
22
|
draggable: Boolean,
|
|
@@ -69,6 +71,16 @@ export default {
|
|
|
69
71
|
e.preventDefault();
|
|
70
72
|
},
|
|
71
73
|
},
|
|
74
|
+
|
|
75
|
+
{
|
|
76
|
+
// iOS workaround for slider stopping if swiping fast
|
|
77
|
+
name: `${pointerMove} ${pointerUp}`,
|
|
78
|
+
el() {
|
|
79
|
+
return this.list;
|
|
80
|
+
},
|
|
81
|
+
handler: noop,
|
|
82
|
+
...pointerOptions,
|
|
83
|
+
},
|
|
72
84
|
],
|
|
73
85
|
|
|
74
86
|
methods: {
|
|
@@ -89,10 +101,10 @@ export default {
|
|
|
89
101
|
this.prevIndex = this.index;
|
|
90
102
|
}
|
|
91
103
|
|
|
92
|
-
on(document, pointerMove, this.move,
|
|
104
|
+
on(document, pointerMove, this.move, pointerOptions);
|
|
93
105
|
|
|
94
106
|
// 'input' event is triggered by video controls
|
|
95
|
-
on(document,
|
|
107
|
+
on(document, pointerUp, this.end, pointerOptions);
|
|
96
108
|
|
|
97
109
|
css(this.list, 'userSelect', 'none');
|
|
98
110
|
},
|
|
@@ -172,8 +184,8 @@ export default {
|
|
|
172
184
|
},
|
|
173
185
|
|
|
174
186
|
end() {
|
|
175
|
-
off(document, pointerMove, this.move,
|
|
176
|
-
off(document,
|
|
187
|
+
off(document, pointerMove, this.move, pointerOptions);
|
|
188
|
+
off(document, pointerUp, this.end, pointerOptions);
|
|
177
189
|
|
|
178
190
|
if (this.dragging) {
|
|
179
191
|
this.dragging = null;
|
|
@@ -5,13 +5,15 @@ import {
|
|
|
5
5
|
css,
|
|
6
6
|
fastdom,
|
|
7
7
|
hasClass,
|
|
8
|
-
height,
|
|
9
8
|
includes,
|
|
10
9
|
isBoolean,
|
|
11
10
|
isFunction,
|
|
12
11
|
isVisible,
|
|
13
12
|
noop,
|
|
13
|
+
offset,
|
|
14
14
|
removeClass,
|
|
15
|
+
scrollParents,
|
|
16
|
+
startsWith,
|
|
15
17
|
toFloat,
|
|
16
18
|
toggleClass,
|
|
17
19
|
toNodes,
|
|
@@ -41,7 +43,7 @@ export default {
|
|
|
41
43
|
|
|
42
44
|
initProps: {
|
|
43
45
|
overflow: '',
|
|
44
|
-
|
|
46
|
+
maxHeight: '',
|
|
45
47
|
paddingTop: '',
|
|
46
48
|
paddingBottom: '',
|
|
47
49
|
marginTop: '',
|
|
@@ -51,7 +53,7 @@ export default {
|
|
|
51
53
|
|
|
52
54
|
hideProps: {
|
|
53
55
|
overflow: 'hidden',
|
|
54
|
-
|
|
56
|
+
maxHeight: 0,
|
|
55
57
|
paddingTop: 0,
|
|
56
58
|
paddingBottom: 0,
|
|
57
59
|
marginTop: 0,
|
|
@@ -66,7 +68,7 @@ export default {
|
|
|
66
68
|
},
|
|
67
69
|
|
|
68
70
|
hasTransition({ animation }) {
|
|
69
|
-
return
|
|
71
|
+
return startsWith(animation[0], 'slide');
|
|
70
72
|
},
|
|
71
73
|
},
|
|
72
74
|
|
|
@@ -81,18 +83,13 @@ export default {
|
|
|
81
83
|
return Promise.reject();
|
|
82
84
|
}
|
|
83
85
|
|
|
84
|
-
if (!animate) {
|
|
85
|
-
Animation.cancel(el);
|
|
86
|
-
Transition.cancel(el);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
86
|
const promise = (
|
|
90
87
|
isFunction(animate)
|
|
91
88
|
? animate
|
|
92
89
|
: animate === false || !this.hasAnimation
|
|
93
|
-
? this
|
|
90
|
+
? toggleInstant(this)
|
|
94
91
|
: this.hasTransition
|
|
95
|
-
?
|
|
92
|
+
? toggleTransition(this)
|
|
96
93
|
: toggleAnimation(this)
|
|
97
94
|
)(el, show);
|
|
98
95
|
|
|
@@ -156,7 +153,25 @@ export default {
|
|
|
156
153
|
},
|
|
157
154
|
};
|
|
158
155
|
|
|
159
|
-
|
|
156
|
+
function toggleInstant({ _toggle }) {
|
|
157
|
+
return (el, show) => {
|
|
158
|
+
Animation.cancel(el);
|
|
159
|
+
Transition.cancel(el);
|
|
160
|
+
return _toggle(el, show);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function toggleTransition(cmp) {
|
|
165
|
+
switch (cmp.animation[0]) {
|
|
166
|
+
case 'slide-left':
|
|
167
|
+
return slideHorizontal(cmp);
|
|
168
|
+
case 'slide-right':
|
|
169
|
+
return slideHorizontal(cmp, true);
|
|
170
|
+
}
|
|
171
|
+
return slide(cmp);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function slide({
|
|
160
175
|
isToggled,
|
|
161
176
|
duration,
|
|
162
177
|
velocity,
|
|
@@ -167,11 +182,14 @@ export function toggleHeight({
|
|
|
167
182
|
}) {
|
|
168
183
|
return (el, show) => {
|
|
169
184
|
const inProgress = Transition.inProgress(el);
|
|
170
|
-
const inner =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
185
|
+
const inner =
|
|
186
|
+
!inProgress && el.hasChildNodes()
|
|
187
|
+
? toFloat(css(el.firstElementChild, 'marginTop')) +
|
|
188
|
+
toFloat(css(el.lastElementChild, 'marginBottom'))
|
|
189
|
+
: 0;
|
|
190
|
+
const currentHeight = isVisible(el) ? toFloat(css(el, 'height')) + inner : 0;
|
|
191
|
+
|
|
192
|
+
const props = inProgress ? css(el, Object.keys(initProps)) : show ? hideProps : initProps;
|
|
175
193
|
|
|
176
194
|
Transition.cancel(el);
|
|
177
195
|
|
|
@@ -179,34 +197,97 @@ export function toggleHeight({
|
|
|
179
197
|
_toggle(el, true);
|
|
180
198
|
}
|
|
181
199
|
|
|
182
|
-
|
|
200
|
+
css(el, 'maxHeight', '');
|
|
183
201
|
|
|
184
202
|
// Update child components first
|
|
185
203
|
fastdom.flush();
|
|
186
204
|
|
|
187
|
-
const endHeight =
|
|
188
|
-
duration = velocity *
|
|
205
|
+
const endHeight = toFloat(css(el, 'height')) + inner;
|
|
206
|
+
duration = velocity * endHeight + duration;
|
|
189
207
|
|
|
190
|
-
|
|
208
|
+
css(el, { ...props, maxHeight: currentHeight });
|
|
191
209
|
|
|
192
210
|
return (
|
|
193
211
|
show
|
|
194
212
|
? Transition.start(
|
|
195
213
|
el,
|
|
196
|
-
{ ...initProps, overflow: 'hidden',
|
|
197
|
-
|
|
214
|
+
{ ...initProps, overflow: 'hidden', maxHeight: endHeight },
|
|
215
|
+
duration * (1 - currentHeight / endHeight),
|
|
198
216
|
transition
|
|
199
217
|
)
|
|
200
218
|
: Transition.start(
|
|
201
219
|
el,
|
|
202
220
|
hideProps,
|
|
203
|
-
|
|
221
|
+
duration * (currentHeight / endHeight),
|
|
204
222
|
transition
|
|
205
223
|
).then(() => _toggle(el, false))
|
|
206
224
|
).then(() => css(el, initProps));
|
|
207
225
|
};
|
|
208
226
|
}
|
|
209
227
|
|
|
228
|
+
function slideHorizontal({ isToggled, duration, velocity, transition, _toggle }, right) {
|
|
229
|
+
return (el, show) => {
|
|
230
|
+
const visible = isVisible(el);
|
|
231
|
+
const marginLeft = toFloat(css(el, 'marginLeft'));
|
|
232
|
+
|
|
233
|
+
Transition.cancel(el);
|
|
234
|
+
|
|
235
|
+
const [scrollElement] = scrollParents(el);
|
|
236
|
+
css(scrollElement, 'overflowX', 'hidden');
|
|
237
|
+
|
|
238
|
+
if (!isToggled(el)) {
|
|
239
|
+
_toggle(el, true);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const width = toFloat(css(el, 'width'));
|
|
243
|
+
duration = velocity * width + duration;
|
|
244
|
+
|
|
245
|
+
const percent = visible ? ((width + marginLeft * (right ? -1 : 1)) / width) * 100 : 0;
|
|
246
|
+
const offsetEl = offset(el);
|
|
247
|
+
const useClipPath = right
|
|
248
|
+
? offsetEl.right < scrollElement.clientWidth
|
|
249
|
+
: Math.round(offsetEl.left) > 0;
|
|
250
|
+
|
|
251
|
+
css(el, {
|
|
252
|
+
clipPath: useClipPath
|
|
253
|
+
? right
|
|
254
|
+
? `polygon(0 0,${percent}% 0,${percent}% 100%,0 100%)`
|
|
255
|
+
: `polygon(${100 - percent}% 0,100% 0,100% 100%,${100 - percent}% 100%)`
|
|
256
|
+
: '',
|
|
257
|
+
marginLeft: (((100 - percent) * (right ? 1 : -1)) / 100) * width,
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
show
|
|
262
|
+
? Transition.start(
|
|
263
|
+
el,
|
|
264
|
+
{
|
|
265
|
+
clipPath: useClipPath ? `polygon(0 0,100% 0,100% 100%,0 100%)` : '',
|
|
266
|
+
marginLeft: 0,
|
|
267
|
+
},
|
|
268
|
+
duration * (1 - percent / 100),
|
|
269
|
+
transition
|
|
270
|
+
)
|
|
271
|
+
: Transition.start(
|
|
272
|
+
el,
|
|
273
|
+
{
|
|
274
|
+
clipPath: useClipPath
|
|
275
|
+
? right
|
|
276
|
+
? `polygon(0 0,0 0,0 100%,0 100%)`
|
|
277
|
+
: `polygon(100% 0,100% 0,100% 100%,100% 100%)`
|
|
278
|
+
: '',
|
|
279
|
+
marginLeft: (right ? 1 : -1) * width,
|
|
280
|
+
},
|
|
281
|
+
duration * (percent / 100),
|
|
282
|
+
transition
|
|
283
|
+
).then(() => _toggle(el, false))
|
|
284
|
+
).then(() => {
|
|
285
|
+
css(scrollElement, 'overflowX', '');
|
|
286
|
+
css(el, { clipPath: '', marginLeft: '' });
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
210
291
|
function toggleAnimation(cmp) {
|
|
211
292
|
return (el, show) => {
|
|
212
293
|
Animation.cancel(el);
|
package/src/js/util/animation.js
CHANGED
|
@@ -5,6 +5,7 @@ import { startsWith, toNodes } from './lang';
|
|
|
5
5
|
import { addClass, hasClass, removeClass, removeClasses } from './class';
|
|
6
6
|
|
|
7
7
|
export function transition(element, props, duration = 400, timing = 'linear') {
|
|
8
|
+
duration = Math.round(duration);
|
|
8
9
|
return Promise.all(
|
|
9
10
|
toNodes(element).map(
|
|
10
11
|
(element) =>
|
|
@@ -94,13 +94,13 @@ export function position(element) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export function offsetPosition(element) {
|
|
97
|
-
const offset = [0, 0];
|
|
98
|
-
|
|
99
97
|
element = toNode(element);
|
|
100
98
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
const offset = [element.offsetTop, element.offsetLeft];
|
|
100
|
+
|
|
101
|
+
while ((element = element.offsetParent)) {
|
|
102
|
+
offset[0] += element.offsetTop + toFloat(css(element, `borderTopWidth`));
|
|
103
|
+
offset[1] += element.offsetLeft + toFloat(css(element, `borderLeftWidth`));
|
|
104
104
|
|
|
105
105
|
if (css(element, 'position') === 'fixed') {
|
|
106
106
|
const win = toWindow(element);
|
|
@@ -108,7 +108,7 @@ export function offsetPosition(element) {
|
|
|
108
108
|
offset[1] += win.scrollX;
|
|
109
109
|
return offset;
|
|
110
110
|
}
|
|
111
|
-
}
|
|
111
|
+
}
|
|
112
112
|
|
|
113
113
|
return offset;
|
|
114
114
|
}
|
package/src/js/util/position.js
CHANGED
package/src/js/util/viewport.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { css } from './style';
|
|
2
2
|
import { isVisible, parents } from './filter';
|
|
3
3
|
import { offset, offsetPosition } from './dimensions';
|
|
4
|
-
import {
|
|
5
|
-
clamp,
|
|
6
|
-
findIndex,
|
|
7
|
-
intersectRect,
|
|
8
|
-
isDocument,
|
|
9
|
-
isUndefined,
|
|
10
|
-
isWindow,
|
|
11
|
-
toFloat,
|
|
12
|
-
toNode,
|
|
13
|
-
toWindow,
|
|
14
|
-
ucfirst,
|
|
15
|
-
} from './lang';
|
|
4
|
+
import { clamp, findIndex, intersectRect, isWindow, toFloat, toWindow, ucfirst } from './lang';
|
|
16
5
|
|
|
17
6
|
export function isInView(element, offsetTop = 0, offsetLeft = 0) {
|
|
18
7
|
if (!isVisible(element)) {
|
|
@@ -35,20 +24,6 @@ export function isInView(element, offsetTop = 0, offsetLeft = 0) {
|
|
|
35
24
|
);
|
|
36
25
|
}
|
|
37
26
|
|
|
38
|
-
export function scrollTop(element, top) {
|
|
39
|
-
if (isWindow(element) || isDocument(element)) {
|
|
40
|
-
element = scrollingElement(element);
|
|
41
|
-
} else {
|
|
42
|
-
element = toNode(element);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (isUndefined(top)) {
|
|
46
|
-
return element.scrollTop;
|
|
47
|
-
} else {
|
|
48
|
-
element.scrollTop = top;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
27
|
export function scrollIntoView(element, { offset: offsetBy = 0 } = {}) {
|
|
53
28
|
const parents = isVisible(element) ? scrollParents(element) : [];
|
|
54
29
|
return parents.reduce(
|
|
@@ -90,7 +65,7 @@ export function scrollIntoView(element, { offset: offsetBy = 0 } = {}) {
|
|
|
90
65
|
(function step() {
|
|
91
66
|
const percent = ease(clamp((Date.now() - start) / duration));
|
|
92
67
|
|
|
93
|
-
scrollTop
|
|
68
|
+
element.scrollTop = scroll + top * percent;
|
|
94
69
|
|
|
95
70
|
// scroll more if we have not reached our destination
|
|
96
71
|
if (percent === 1) {
|
|
@@ -128,7 +103,7 @@ export function scrolledOver(element, startOffset = 0, endOffset = 0) {
|
|
|
128
103
|
return clamp((scrollTop - start) / (end - start));
|
|
129
104
|
}
|
|
130
105
|
|
|
131
|
-
export function scrollParents(element, overflowRe = /auto|scroll|hidden/, scrollable = false) {
|
|
106
|
+
export function scrollParents(element, overflowRe = /auto|scroll|hidden|clip/, scrollable = false) {
|
|
132
107
|
const scrollEl = scrollingElement(element);
|
|
133
108
|
|
|
134
109
|
let ancestors = parents(element).reverse();
|
|
@@ -151,18 +126,33 @@ export function scrollParents(element, overflowRe = /auto|scroll|hidden/, scroll
|
|
|
151
126
|
}
|
|
152
127
|
|
|
153
128
|
export function offsetViewport(scrollElement) {
|
|
154
|
-
|
|
129
|
+
const window = toWindow(scrollElement);
|
|
130
|
+
const {
|
|
131
|
+
document: { body, documentElement },
|
|
132
|
+
} = window;
|
|
133
|
+
let viewportElement =
|
|
134
|
+
scrollElement === scrollingElement(scrollElement) || scrollElement === body
|
|
135
|
+
? window
|
|
136
|
+
: scrollElement;
|
|
137
|
+
|
|
138
|
+
const { visualViewport } = window;
|
|
139
|
+
if (isWindow(viewportElement) && visualViewport) {
|
|
140
|
+
let { height, width, scale, pageTop: top, pageLeft: left } = visualViewport;
|
|
141
|
+
height = Math.round(height * scale);
|
|
142
|
+
width = Math.round(width * scale);
|
|
143
|
+
return { height, width, top, left, bottom: top + height, right: left + width };
|
|
144
|
+
}
|
|
155
145
|
|
|
156
146
|
let rect = offset(viewportElement);
|
|
157
147
|
for (let [prop, dir, start, end] of [
|
|
158
148
|
['width', 'x', 'left', 'right'],
|
|
159
149
|
['height', 'y', 'top', 'bottom'],
|
|
160
150
|
]) {
|
|
161
|
-
if (
|
|
162
|
-
rect[start] += toFloat(css(viewportElement, `border${ucfirst(start)}Width`));
|
|
163
|
-
} else {
|
|
151
|
+
if (isWindow(viewportElement)) {
|
|
164
152
|
// iOS 12 returns <body> as scrollingElement
|
|
165
|
-
viewportElement =
|
|
153
|
+
viewportElement = documentElement;
|
|
154
|
+
} else {
|
|
155
|
+
rect[start] += toFloat(css(viewportElement, `border${ucfirst(start)}Width`));
|
|
166
156
|
}
|
|
167
157
|
rect[prop] = rect[dir] = viewportElement[`client${ucfirst(prop)}`];
|
|
168
158
|
rect[end] = rect[prop] + rect[start];
|
|
@@ -173,7 +163,3 @@ export function offsetViewport(scrollElement) {
|
|
|
173
163
|
function scrollingElement(element) {
|
|
174
164
|
return toWindow(element).document.scrollingElement;
|
|
175
165
|
}
|
|
176
|
-
|
|
177
|
-
function getViewport(scrollElement) {
|
|
178
|
-
return scrollElement === scrollingElement(scrollElement) ? window : scrollElement;
|
|
179
|
-
}
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Component: `uk-drop`
|
|
5
5
|
//
|
|
6
|
-
// Modifiers: `uk-drop-
|
|
7
|
-
// `uk-drop-bottom-*`
|
|
8
|
-
// `uk-drop-left-*`
|
|
9
|
-
// `uk-drop-right-*`
|
|
6
|
+
// Modifiers: `uk-drop-stretch`
|
|
10
7
|
// `uk-drop-stack`
|
|
11
8
|
// `uk-drop-grid`
|
|
12
9
|
//
|
|
@@ -22,6 +19,7 @@
|
|
|
22
19
|
|
|
23
20
|
@drop-z-index: @global-z-index + 20;
|
|
24
21
|
@drop-margin: @global-margin;
|
|
22
|
+
@drop-viewport-margin: 15px;
|
|
25
23
|
@drop-width: 300px;
|
|
26
24
|
|
|
27
25
|
|
|
@@ -42,7 +40,7 @@
|
|
|
42
40
|
position: absolute;
|
|
43
41
|
z-index: @drop-z-index;
|
|
44
42
|
--uk-position-offset: @drop-margin;
|
|
45
|
-
--uk-position-viewport-offset:
|
|
43
|
+
--uk-position-viewport-offset: @drop-viewport-margin;
|
|
46
44
|
/* 3 */
|
|
47
45
|
box-sizing: border-box;
|
|
48
46
|
width: @drop-width;
|
|
@@ -52,6 +50,22 @@
|
|
|
52
50
|
.uk-drop.uk-open { display: block; }
|
|
53
51
|
|
|
54
52
|
|
|
53
|
+
/* Stretch modifier
|
|
54
|
+
========================================================================== */
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* 1. Allow scrolling
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
.uk-drop-stretch {
|
|
61
|
+
--uk-position-offset: 0;
|
|
62
|
+
--uk-position-viewport-offset: 0;
|
|
63
|
+
/* 1 */
|
|
64
|
+
overflow-y: auto;
|
|
65
|
+
-webkit-overflow-scrolling: touch;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
55
69
|
/* Grid modifiers
|
|
56
70
|
========================================================================== */
|
|
57
71
|
|
|
@@ -5,10 +5,7 @@
|
|
|
5
5
|
//
|
|
6
6
|
// Adopted: `uk-dropdown-nav`
|
|
7
7
|
//
|
|
8
|
-
// Modifiers: `uk-dropdown-
|
|
9
|
-
// `uk-dropdown-bottom-*`
|
|
10
|
-
// `uk-dropdown-left-*`
|
|
11
|
-
// `uk-dropdown-right-*`
|
|
8
|
+
// Modifiers: `uk-dropdown-stretch`
|
|
12
9
|
// `uk-dropdown-stack`
|
|
13
10
|
// `uk-dropdown-grid`
|
|
14
11
|
//
|
|
@@ -22,6 +19,7 @@
|
|
|
22
19
|
|
|
23
20
|
@dropdown-z-index: @global-z-index + 20;
|
|
24
21
|
@dropdown-margin: @global-small-margin;
|
|
22
|
+
@dropdown-viewport-margin: 15px;
|
|
25
23
|
@dropdown-min-width: 200px;
|
|
26
24
|
@dropdown-padding: 15px;
|
|
27
25
|
@dropdown-background: @global-muted-background;
|
|
@@ -55,7 +53,7 @@
|
|
|
55
53
|
position: absolute;
|
|
56
54
|
z-index: @dropdown-z-index;
|
|
57
55
|
--uk-position-offset: @dropdown-margin;
|
|
58
|
-
--uk-position-viewport-offset:
|
|
56
|
+
--uk-position-viewport-offset: @dropdown-viewport-margin;
|
|
59
57
|
/* 3 */
|
|
60
58
|
box-sizing: border-box;
|
|
61
59
|
min-width: @dropdown-min-width;
|
|
@@ -71,6 +69,23 @@
|
|
|
71
69
|
.uk-dropdown.uk-open { display: block; }
|
|
72
70
|
|
|
73
71
|
|
|
72
|
+
/* Stretch modifier
|
|
73
|
+
========================================================================== */
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
* 1. Allow scrolling
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
.uk-dropdown-stretch {
|
|
80
|
+
--uk-position-offset: 0;
|
|
81
|
+
--uk-position-viewport-offset: 0;
|
|
82
|
+
/* 1 */
|
|
83
|
+
overflow-y: auto;
|
|
84
|
+
-webkit-overflow-scrolling: touch;
|
|
85
|
+
.hook-dropdown-stretch();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
74
89
|
/* Nav
|
|
75
90
|
* Adopts `uk-nav`
|
|
76
91
|
========================================================================== */
|
|
@@ -145,6 +160,7 @@
|
|
|
145
160
|
.hook-dropdown-misc();
|
|
146
161
|
|
|
147
162
|
.hook-dropdown() {}
|
|
163
|
+
.hook-dropdown-stretch() {}
|
|
148
164
|
.hook-dropdown-nav() {}
|
|
149
165
|
.hook-dropdown-nav-item() {}
|
|
150
166
|
.hook-dropdown-nav-item-hover() {}
|
|
@@ -193,20 +193,20 @@
|
|
|
193
193
|
/* Remove
|
|
194
194
|
========================================================================== */
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
196
|
+
.uk-margin-remove { margin: 0 !important; }
|
|
197
|
+
.uk-margin-remove-top { margin-top: 0 !important; }
|
|
198
|
+
.uk-margin-remove-bottom { margin-bottom: 0 !important; }
|
|
199
|
+
.uk-margin-remove-left { margin-left: 0 !important; }
|
|
200
|
+
.uk-margin-remove-right { margin-right: 0 !important; }
|
|
201
|
+
|
|
202
|
+
.uk-margin-remove-vertical {
|
|
203
|
+
margin-top: 0 !important;
|
|
204
|
+
margin-bottom: 0 !important;
|
|
205
|
+
}
|
|
206
206
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
.uk-margin-remove-adjacent + *,
|
|
208
|
+
.uk-margin-remove-first-child > :first-child { margin-top: 0 !important; }
|
|
209
|
+
.uk-margin-remove-last-child > :last-child { margin-bottom: 0 !important; }
|
|
210
210
|
|
|
211
211
|
/* Phone landscape and bigger */
|
|
212
212
|
@media (min-width: @breakpoint-small) {
|
|
@@ -241,7 +241,6 @@
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
|
|
244
|
-
|
|
245
244
|
// Hooks
|
|
246
245
|
// ========================================================================
|
|
247
246
|
|