uikit 3.13.9 → 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.
- package/CHANGELOG.md +41 -1
- package/build/build.js +4 -1
- package/dist/css/uikit-core-rtl.css +49 -8
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +49 -8
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +49 -6
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +49 -6
- 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 +7 -3
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +7 -3
- 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 +21 -12
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +21 -12
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +2 -2
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +21 -12
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +1 -1
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +2 -2
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +62 -30
- 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 +433 -314
- 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 +480 -322
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/components/slider.js +1 -1
- package/src/js/components/sortable.js +2 -3
- package/src/js/components/tooltip.js +38 -3
- package/src/js/core/cover.js +27 -14
- package/src/js/core/drop.js +40 -17
- package/src/js/core/height-match.js +1 -1
- package/src/js/core/margin.js +9 -2
- package/src/js/core/navbar.js +18 -6
- package/src/js/core/scrollspy-nav.js +6 -11
- package/src/js/core/sticky.js +58 -22
- package/src/js/core/toggle.js +8 -8
- package/src/js/mixin/media.js +12 -9
- package/src/js/mixin/modal.js +6 -2
- package/src/js/mixin/parallax.js +8 -3
- package/src/js/mixin/position.js +24 -24
- package/src/js/uikit-core.js +0 -4
- package/src/js/util/lang.js +34 -42
- package/src/js/util/position.js +180 -125
- package/src/js/util/viewport.js +42 -22
- package/src/less/components/drop.less +0 -1
- package/src/less/components/dropdown.less +11 -1
- package/src/less/components/icon.less +3 -0
- package/src/less/components/nav.less +23 -0
- package/src/less/components/navbar.less +26 -2
- package/src/less/components/search.less +2 -0
- package/src/less/components/sticky.less +8 -3
- package/src/less/components/utility.less +1 -0
- package/src/less/theme/dropdown.less +4 -0
- package/src/less/theme/nav.less +6 -0
- package/src/less/theme/navbar.less +4 -0
- package/src/less/theme/search.less +6 -0
- package/src/scss/components/drop.scss +0 -1
- package/src/scss/components/dropdown.scss +11 -1
- package/src/scss/components/icon.scss +3 -0
- package/src/scss/components/nav.scss +23 -0
- package/src/scss/components/navbar.scss +26 -2
- package/src/scss/components/search.scss +2 -0
- package/src/scss/components/sticky.scss +8 -3
- package/src/scss/components/utility.scss +1 -0
- package/src/scss/mixins-theme.scss +5 -0
- package/src/scss/mixins.scss +5 -0
- package/src/scss/theme/dropdown.scss +4 -0
- package/src/scss/theme/nav.scss +6 -0
- package/src/scss/theme/navbar.scss +4 -0
- package/src/scss/theme/search.scss +6 -0
- package/src/scss/variables-theme.scss +5 -1
- package/src/scss/variables.scss +5 -1
- package/tests/alert.html +1 -1
- package/tests/animation.html +216 -214
- package/tests/drop.html +154 -80
- package/tests/dropdown.html +16 -2
- package/tests/nav.html +27 -0
- package/tests/navbar.html +56 -5
- package/tests/parallax.html +5 -5
- package/tests/position.html +38 -39
- package/tests/sticky-navbar.html +6 -6
- package/tests/sticky-parallax.html +29 -13
- package/tests/sticky.html +300 -49
- package/src/js/core/core.js +0 -25
package/src/js/mixin/parallax.js
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
createEvent,
|
|
5
5
|
css,
|
|
6
6
|
Dimensions,
|
|
7
|
-
each,
|
|
8
7
|
findIndex,
|
|
9
8
|
isNumber,
|
|
10
9
|
isString,
|
|
@@ -65,7 +64,9 @@ export default {
|
|
|
65
64
|
|
|
66
65
|
methods: {
|
|
67
66
|
reset() {
|
|
68
|
-
|
|
67
|
+
for (const prop in this.getCss(0)) {
|
|
68
|
+
css(this.$el, prop, '');
|
|
69
|
+
}
|
|
69
70
|
},
|
|
70
71
|
|
|
71
72
|
getCss(percent) {
|
|
@@ -79,12 +80,16 @@ export default {
|
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
function transformFn(prop, el, stops) {
|
|
82
|
-
|
|
83
|
+
let unit = getUnit(stops) || { x: 'px', y: 'px', rotate: 'deg' }[prop] || '';
|
|
83
84
|
let transformFn;
|
|
84
85
|
|
|
85
86
|
if (prop === 'x' || prop === 'y') {
|
|
86
87
|
prop = `translate${ucfirst(prop)}`;
|
|
87
88
|
transformFn = (stop) => toFloat(toFloat(stop).toFixed(unit === 'px' ? 0 : 6));
|
|
89
|
+
} else if (prop === 'scale') {
|
|
90
|
+
unit = '';
|
|
91
|
+
transformFn = (stop) =>
|
|
92
|
+
getUnit([stop]) ? toPx(stop, 'width', el, true) / el.offsetWidth : stop;
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
if (stops.length === 1) {
|
package/src/js/mixin/position.js
CHANGED
|
@@ -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.
|
|
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
|
|
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
|
|
48
|
-
element,
|
|
49
|
-
target,
|
|
50
|
-
|
|
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.
|
|
61
|
-
|
|
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
|
-
|
|
65
|
-
|
|
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
|
};
|
package/src/js/uikit-core.js
CHANGED
|
@@ -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;
|
package/src/js/util/lang.js
CHANGED
|
@@ -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
|
-
|
|
208
|
-
|
|
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
|
-
|
|
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
|
-
|
|
235
|
-
|
|
214
|
+
function contain(dimensions, maxDimensions) {
|
|
215
|
+
dimensions = { ...dimensions };
|
|
236
216
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
(dimensions
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
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);
|
package/src/js/util/position.js
CHANGED
|
@@ -1,156 +1,211 @@
|
|
|
1
1
|
import { offset } from './dimensions';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const dirs =
|
|
6
|
-
width
|
|
7
|
-
height
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export function positionAt(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
|
|
40
|
-
|
|
78
|
+
const willFlip =
|
|
79
|
+
!intersectLine(position, targetDim, i) && intersectLine(position, targetDim, 1 - i);
|
|
41
80
|
|
|
42
|
-
|
|
43
|
-
position.top += elOffset['y'];
|
|
81
|
+
viewport = getIntersectionArea(...viewports.filter(Boolean).map(offsetViewport));
|
|
44
82
|
|
|
45
|
-
|
|
46
|
-
|
|
83
|
+
if (viewportPadding) {
|
|
84
|
+
viewport[start] += viewportPadding;
|
|
85
|
+
viewport[end] -= viewportPadding;
|
|
86
|
+
}
|
|
47
87
|
|
|
48
|
-
if (boundary && !
|
|
49
|
-
|
|
88
|
+
if (boundary && !willFlip && position[prop] <= offset(boundary)[prop]) {
|
|
89
|
+
viewport = getIntersectionArea(viewport, offset(boundary));
|
|
50
90
|
}
|
|
51
91
|
|
|
52
|
-
|
|
92
|
+
const isInStartBoundary = position[start] >= viewport[start];
|
|
93
|
+
const isInEndBoundary = position[end] <= viewport[end];
|
|
53
94
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
172
|
+
return offsetPosition;
|
|
173
|
+
}
|
|
115
174
|
|
|
116
|
-
|
|
175
|
+
function moveBy(start, end, dim) {
|
|
176
|
+
return start === 'center' ? dim / 2 : start === end ? dim : 0;
|
|
117
177
|
}
|
|
118
178
|
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
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
|
|
150
|
-
const [
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
}
|