uikit 3.13.2-dev.13a8eb3ff → 3.13.2-dev.696f00752
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/.eslintrc.json +9 -0
- package/CHANGELOG.md +11 -0
- package/dist/css/uikit-core-rtl.css +15 -63
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +15 -63
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +15 -63
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +15 -63
- 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 +1 -1
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +1 -1
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +60 -31
- 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 +207 -185
- 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 +209 -188
- package/dist/js/uikit.min.js +1 -1
- package/package.json +1 -1
- package/src/js/components/tooltip.js +2 -3
- package/src/js/core/drop.js +7 -10
- package/src/js/core/navbar.js +10 -5
- package/src/js/core/sticky.js +1 -1
- package/src/js/mixin/media.js +4 -4
- package/src/js/mixin/position.js +53 -24
- package/src/js/util/dimensions.js +2 -2
- package/src/js/util/position.js +125 -129
- package/src/js/util/style.js +13 -19
- package/src/less/components/drop.less +3 -11
- package/src/less/components/dropdown.less +3 -11
- package/src/less/components/navbar.less +11 -12
- package/src/less/components/tooltip.less +2 -11
- package/src/scss/components/drop.scss +3 -11
- package/src/scss/components/dropdown.scss +3 -11
- package/src/scss/components/navbar.scss +11 -12
- package/src/scss/components/tooltip.scss +2 -11
- package/src/scss/variables-theme.scss +5 -4
- package/src/scss/variables.scss +5 -4
- package/tests/drop.html +1 -1
- package/tests/position.html +38 -39
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "uikit",
|
|
3
3
|
"title": "UIkit",
|
|
4
4
|
"description": "UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.",
|
|
5
|
-
"version": "3.13.2-dev.
|
|
5
|
+
"version": "3.13.2-dev.696f00752",
|
|
6
6
|
"main": "dist/js/uikit.js",
|
|
7
7
|
"style": "dist/css/uikit.css",
|
|
8
8
|
"sideEffects": [
|
|
@@ -35,7 +35,6 @@ export default {
|
|
|
35
35
|
animation: ['uk-animation-scale-up'],
|
|
36
36
|
duration: 100,
|
|
37
37
|
cls: 'uk-active',
|
|
38
|
-
clsPos: 'uk-tooltip',
|
|
39
38
|
},
|
|
40
39
|
|
|
41
40
|
beforeConnect() {
|
|
@@ -91,8 +90,8 @@ export default {
|
|
|
91
90
|
_show() {
|
|
92
91
|
this.tooltip = append(
|
|
93
92
|
this.container,
|
|
94
|
-
`<div class="
|
|
95
|
-
<div class="
|
|
93
|
+
`<div class="uk-${this.$options.name}">
|
|
94
|
+
<div class="uk-${this.$options.name}-inner">${this.title}</div>
|
|
96
95
|
</div>`
|
|
97
96
|
);
|
|
98
97
|
|
package/src/js/core/drop.js
CHANGED
|
@@ -63,7 +63,7 @@ export default {
|
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
connected() {
|
|
66
|
-
this.
|
|
66
|
+
this.clsDrop = this.$props.clsDrop || `uk-${this.$options.name}`;
|
|
67
67
|
addClass(this.$el, this.clsDrop);
|
|
68
68
|
|
|
69
69
|
if (this.toggle && !this.target) {
|
|
@@ -129,7 +129,7 @@ export default {
|
|
|
129
129
|
if (this.isToggled()) {
|
|
130
130
|
this.hide(false);
|
|
131
131
|
} else {
|
|
132
|
-
this.show(toggle
|
|
132
|
+
this.show(toggle?.$el, false);
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
},
|
|
@@ -141,7 +141,7 @@ export default {
|
|
|
141
141
|
|
|
142
142
|
handler(e, toggle) {
|
|
143
143
|
e.preventDefault();
|
|
144
|
-
this.show(toggle
|
|
144
|
+
this.show(toggle?.$el);
|
|
145
145
|
},
|
|
146
146
|
},
|
|
147
147
|
|
|
@@ -352,23 +352,20 @@ export default {
|
|
|
352
352
|
},
|
|
353
353
|
|
|
354
354
|
position() {
|
|
355
|
-
const boundary =
|
|
355
|
+
const boundary = query(this.boundary, this.$el) || window;
|
|
356
356
|
removeClass(this.$el, `${this.clsDrop}-stack`);
|
|
357
357
|
toggleClass(this.$el, `${this.clsDrop}-boundary`, this.boundaryAlign);
|
|
358
358
|
|
|
359
359
|
const boundaryOffset = offset(boundary);
|
|
360
|
-
const
|
|
360
|
+
const targetOffset = offset(this.target);
|
|
361
|
+
const alignTo = this.boundaryAlign ? boundaryOffset : targetOffset;
|
|
361
362
|
|
|
362
363
|
if (this.align === 'justify') {
|
|
363
364
|
const prop = this.getAxis() === 'y' ? 'width' : 'height';
|
|
364
365
|
css(this.$el, prop, alignTo[prop]);
|
|
365
366
|
} else if (
|
|
366
|
-
boundary &&
|
|
367
367
|
this.$el.offsetWidth >
|
|
368
|
-
|
|
369
|
-
boundaryOffset.right - alignTo.left,
|
|
370
|
-
alignTo.right - boundaryOffset.left
|
|
371
|
-
)
|
|
368
|
+
Math.max(boundaryOffset.right - alignTo.left, alignTo.right - boundaryOffset.left)
|
|
372
369
|
) {
|
|
373
370
|
addClass(this.$el, `${this.clsDrop}-stack`);
|
|
374
371
|
}
|
package/src/js/core/navbar.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
isVisible,
|
|
17
17
|
matches,
|
|
18
18
|
noop,
|
|
19
|
+
offset,
|
|
19
20
|
once,
|
|
20
21
|
parent,
|
|
21
22
|
query,
|
|
@@ -274,10 +275,16 @@ export default {
|
|
|
274
275
|
return this.dropbar;
|
|
275
276
|
},
|
|
276
277
|
|
|
277
|
-
handler() {
|
|
278
|
+
handler(_, { $el }) {
|
|
279
|
+
if (!hasClass($el, this.clsDrop)) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
278
283
|
if (!parent(this.dropbar)) {
|
|
279
284
|
after(this.dropbarAnchor || this.$el, this.dropbar);
|
|
280
285
|
}
|
|
286
|
+
|
|
287
|
+
addClass($el, `${this.clsDrop}-dropbar`);
|
|
281
288
|
},
|
|
282
289
|
},
|
|
283
290
|
|
|
@@ -297,12 +304,10 @@ export default {
|
|
|
297
304
|
return;
|
|
298
305
|
}
|
|
299
306
|
|
|
300
|
-
this.clsDrop && addClass($el, `${this.clsDrop}-dropbar`);
|
|
301
|
-
|
|
302
307
|
if (dir === 'bottom') {
|
|
303
308
|
this.transitionTo(
|
|
304
|
-
$el.
|
|
305
|
-
|
|
309
|
+
offset($el).bottom -
|
|
310
|
+
offset(this.dropbar).top +
|
|
306
311
|
toFloat(css($el, 'marginBottom')),
|
|
307
312
|
$el
|
|
308
313
|
);
|
package/src/js/core/sticky.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
height as getHeight,
|
|
15
15
|
offset as getOffset,
|
|
16
16
|
getScrollingElement,
|
|
17
|
+
intersectRect,
|
|
17
18
|
isString,
|
|
18
19
|
isVisible,
|
|
19
20
|
noop,
|
|
@@ -29,7 +30,6 @@ import {
|
|
|
29
30
|
toPx,
|
|
30
31
|
trigger,
|
|
31
32
|
within,
|
|
32
|
-
intersectRect,
|
|
33
33
|
} from 'uikit-util';
|
|
34
34
|
|
|
35
35
|
export default {
|
package/src/js/mixin/media.js
CHANGED
package/src/js/mixin/position.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
$,
|
|
3
3
|
flipPosition,
|
|
4
|
+
getCssVar,
|
|
4
5
|
offset as getOffset,
|
|
6
|
+
includes,
|
|
5
7
|
isNumeric,
|
|
6
8
|
isRtl,
|
|
7
9
|
positionAt,
|
|
8
|
-
|
|
9
|
-
toggleClass,
|
|
10
|
+
toPx,
|
|
10
11
|
} from 'uikit-util';
|
|
11
12
|
|
|
12
13
|
export default {
|
|
@@ -14,14 +15,12 @@ export default {
|
|
|
14
15
|
pos: String,
|
|
15
16
|
offset: null,
|
|
16
17
|
flip: Boolean,
|
|
17
|
-
clsPos: String,
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
data: {
|
|
21
21
|
pos: `bottom-${isRtl ? 'right' : 'left'}`,
|
|
22
22
|
flip: true,
|
|
23
23
|
offset: false,
|
|
24
|
-
clsPos: '',
|
|
25
24
|
},
|
|
26
25
|
|
|
27
26
|
connected() {
|
|
@@ -32,13 +31,11 @@ export default {
|
|
|
32
31
|
|
|
33
32
|
methods: {
|
|
34
33
|
positionAt(element, target, boundary) {
|
|
35
|
-
removeClasses(element, `${this.clsPos}-(top|bottom|left|right)(-[a-z]+)?`);
|
|
36
|
-
|
|
37
|
-
let { offset } = this;
|
|
38
34
|
const axis = this.getAxis();
|
|
39
35
|
const dir = this.pos[0];
|
|
40
36
|
const align = this.pos[1];
|
|
41
37
|
|
|
38
|
+
let { offset } = this;
|
|
42
39
|
if (!isNumeric(offset)) {
|
|
43
40
|
const node = $(offset);
|
|
44
41
|
offset = node
|
|
@@ -46,28 +43,60 @@ export default {
|
|
|
46
43
|
getOffset(target)[axis === 'x' ? 'right' : 'bottom']
|
|
47
44
|
: 0;
|
|
48
45
|
}
|
|
46
|
+
offset += toPx(getCssVar('position-margin-offset', element));
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
this.dir = axis === 'x' ? x : y;
|
|
64
|
-
this.align = axis === 'x' ? y : x;
|
|
48
|
+
positionAt(element, target, {
|
|
49
|
+
boundary,
|
|
50
|
+
flip: this.flip,
|
|
51
|
+
attach: {
|
|
52
|
+
element: axis === 'x' ? [flipPosition(dir), align] : [align, flipPosition(dir)],
|
|
53
|
+
target: axis === 'x' ? [dir, align] : [align, dir],
|
|
54
|
+
},
|
|
55
|
+
offset:
|
|
56
|
+
axis === 'x'
|
|
57
|
+
? [dir === 'left' ? -offset : +offset, 0]
|
|
58
|
+
: [0, dir === 'top' ? -offset : +offset],
|
|
59
|
+
});
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
[this.dir, this.align] = getAlignment(element, target);
|
|
62
|
+
console.log(this.dir, this.align);
|
|
67
63
|
},
|
|
68
64
|
|
|
69
65
|
getAxis() {
|
|
70
|
-
return
|
|
66
|
+
return includes(['top', 'bottom'], this.dir) ? 'y' : 'x';
|
|
71
67
|
},
|
|
72
68
|
},
|
|
73
69
|
};
|
|
70
|
+
|
|
71
|
+
function getAlignment(el, target) {
|
|
72
|
+
const elOffset = getOffset(el);
|
|
73
|
+
const targetOffset = getOffset(target);
|
|
74
|
+
const properties = [
|
|
75
|
+
['left', 'right'],
|
|
76
|
+
['top', 'bottom'],
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
let dir;
|
|
80
|
+
for (const props of properties) {
|
|
81
|
+
if (elOffset[props[0]] > targetOffset[props[1]]) {
|
|
82
|
+
dir = props[1];
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (elOffset[props[1]] < targetOffset[props[0]]) {
|
|
86
|
+
dir = props[0];
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let align;
|
|
92
|
+
const props = includes(properties[0], dir) ? properties[1] : properties[0];
|
|
93
|
+
if (elOffset[props[0]] === targetOffset[props[0]]) {
|
|
94
|
+
align = props[0];
|
|
95
|
+
} else if (elOffset[props[1]] === targetOffset[props[1]]) {
|
|
96
|
+
align = props[1];
|
|
97
|
+
} else {
|
|
98
|
+
align = 'center';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return [dir, align];
|
|
102
|
+
}
|
|
@@ -41,8 +41,8 @@ export function offset(element, coordinates) {
|
|
|
41
41
|
const offsetBy = { height: scrollY, width: scrollX };
|
|
42
42
|
|
|
43
43
|
for (const dir in dirs) {
|
|
44
|
-
for (const
|
|
45
|
-
currentOffset[
|
|
44
|
+
for (const prop of dirs[dir]) {
|
|
45
|
+
currentOffset[prop] += offsetBy[dir];
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/js/util/position.js
CHANGED
|
@@ -1,156 +1,152 @@
|
|
|
1
1
|
import { offset } from './dimensions';
|
|
2
|
-
import {
|
|
2
|
+
import { clamp, includes } from './lang';
|
|
3
3
|
import { getViewport, scrollParents } from './viewport';
|
|
4
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
|
-
|
|
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 in dirs) {
|
|
42
|
+
const [prop, dir, start, end] = dirs[i];
|
|
43
|
+
position[start] = position[dir] =
|
|
44
|
+
targetOffset[start] +
|
|
45
|
+
moveBy(attach.target[i], end, targetOffset[prop]) -
|
|
46
|
+
moveBy(attach.element[i], end, position[prop]) +
|
|
47
|
+
+offsetBy[i];
|
|
48
|
+
position[end] = position[start] + position[prop];
|
|
27
49
|
}
|
|
50
|
+
return position;
|
|
51
|
+
}
|
|
28
52
|
|
|
29
|
-
|
|
53
|
+
function attachToWithFlip(element, target, options) {
|
|
54
|
+
const position = attachTo(element, target, options);
|
|
30
55
|
const targetDim = offset(target);
|
|
31
|
-
const
|
|
56
|
+
const viewports = scrollParents(element).map(getViewport);
|
|
57
|
+
|
|
58
|
+
let {
|
|
59
|
+
flip,
|
|
60
|
+
attach: { element: elAttach, target: targetAttach },
|
|
61
|
+
offset: elOffset,
|
|
62
|
+
boundary,
|
|
63
|
+
viewport,
|
|
64
|
+
} = options;
|
|
32
65
|
|
|
33
|
-
|
|
34
|
-
moveTo(position, targetAttach, targetDim, 1);
|
|
66
|
+
viewports.push(viewport);
|
|
35
67
|
|
|
36
|
-
|
|
37
|
-
|
|
68
|
+
for (const i in dirs) {
|
|
69
|
+
const [prop, dir, start, end] = dirs[i];
|
|
38
70
|
|
|
39
|
-
|
|
40
|
-
|
|
71
|
+
if (flip !== true && !includes(flip, dir)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
41
74
|
|
|
42
|
-
|
|
43
|
-
|
|
75
|
+
const willFlip =
|
|
76
|
+
!intersectLine(position, targetDim, i) && intersectLine(position, targetDim, 1 - i);
|
|
44
77
|
|
|
45
|
-
|
|
46
|
-
|
|
78
|
+
viewport = getIntersectionArea(...viewports, willFlip ? null : boundary);
|
|
79
|
+
const isInStartBoundary = position[start] >= viewport[start];
|
|
80
|
+
const isInEndBoundary = position[end] <= viewport[end];
|
|
47
81
|
|
|
48
|
-
if (
|
|
49
|
-
|
|
82
|
+
if (isInStartBoundary && isInEndBoundary) {
|
|
83
|
+
continue;
|
|
50
84
|
}
|
|
51
85
|
|
|
52
|
-
|
|
86
|
+
let offsetBy;
|
|
53
87
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
88
|
+
// Flip
|
|
89
|
+
if (willFlip) {
|
|
90
|
+
if (
|
|
91
|
+
(elAttach[i] === end && isInStartBoundary) ||
|
|
92
|
+
(elAttach[i] === start && isInEndBoundary)
|
|
93
|
+
) {
|
|
94
|
+
continue;
|
|
57
95
|
}
|
|
58
96
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
position[
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
(elAttach[dir] === 'center' &&
|
|
84
|
-
(apply(centerOffset, centerTargetOffset) ||
|
|
85
|
-
apply(-centerOffset, -centerTargetOffset))) ||
|
|
86
|
-
apply(elemOffset, targetOffset)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
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
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
97
|
+
offsetBy =
|
|
98
|
+
(elAttach[i] === start
|
|
99
|
+
? -position[prop]
|
|
100
|
+
: elAttach[i] === end
|
|
101
|
+
? position[prop]
|
|
102
|
+
: 0) +
|
|
103
|
+
(targetAttach[i] === start
|
|
104
|
+
? targetDim[prop]
|
|
105
|
+
: targetAttach[i] === end
|
|
106
|
+
? -targetDim[prop]
|
|
107
|
+
: 0) -
|
|
108
|
+
elOffset[i] * 2;
|
|
109
|
+
|
|
110
|
+
// Move
|
|
111
|
+
} else {
|
|
112
|
+
offsetBy =
|
|
113
|
+
clamp(
|
|
114
|
+
clamp(position[start], viewport[start], viewport[end] - position[prop]),
|
|
115
|
+
targetDim[start] - position[prop] + elOffset[i],
|
|
116
|
+
targetDim[end] - elOffset[i]
|
|
117
|
+
) - position[start];
|
|
118
|
+
}
|
|
113
119
|
|
|
114
|
-
|
|
120
|
+
position[start] = position[dir] = position[start] + offsetBy;
|
|
121
|
+
position[end] += offsetBy;
|
|
122
|
+
}
|
|
115
123
|
|
|
116
|
-
return
|
|
124
|
+
return position;
|
|
117
125
|
}
|
|
118
126
|
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
if (attach[dir] === alignFlip) {
|
|
122
|
-
position[align] += dim[prop] * factor;
|
|
123
|
-
} else if (attach[dir] === 'center') {
|
|
124
|
-
position[align] += (dim[prop] * factor) / 2;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
+
function moveBy(start, end, dim) {
|
|
128
|
+
return start === 'center' ? dim / 2 : start === end ? dim : 0;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
131
|
+
function getIntersectionArea(...elements) {
|
|
132
|
+
let intersection;
|
|
133
|
+
for (const el of elements.filter(Boolean)) {
|
|
134
|
+
const rect = offset(el);
|
|
135
|
+
if (!intersection) {
|
|
136
|
+
intersection = rect;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
for (const prop of ['left', 'top']) {
|
|
140
|
+
intersection[prop] = Math.max(rect[prop], intersection[prop]);
|
|
141
|
+
}
|
|
142
|
+
for (const prop of ['right', 'bottom']) {
|
|
143
|
+
intersection[prop] = Math.min(rect[prop], intersection[prop]);
|
|
144
|
+
}
|
|
141
145
|
}
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
x: x.test(pos[0]) ? pos[0] : 'center',
|
|
145
|
-
y: y.test(pos[1]) ? pos[1] : 'center',
|
|
146
|
-
};
|
|
146
|
+
return intersection;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
function
|
|
150
|
-
const [
|
|
151
|
-
|
|
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
|
-
};
|
|
149
|
+
function intersectLine(dimA, dimB, dir) {
|
|
150
|
+
const [, , start, end] = dirs[dir];
|
|
151
|
+
return dimA[end] > dimB[start] && dimB[end] > dimA[start];
|
|
156
152
|
}
|
package/src/js/util/style.js
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
isUndefined,
|
|
10
10
|
memoize,
|
|
11
11
|
toNodes,
|
|
12
|
-
toWindow,
|
|
13
12
|
} from './lang';
|
|
14
13
|
|
|
15
14
|
const cssNumber = {
|
|
@@ -37,21 +36,22 @@ export function css(element, property, value, priority = '') {
|
|
|
37
36
|
property = propName(property);
|
|
38
37
|
|
|
39
38
|
if (isUndefined(value)) {
|
|
40
|
-
return
|
|
41
|
-
} else if (!value && !isNumber(value)) {
|
|
42
|
-
element.style.removeProperty(property);
|
|
39
|
+
return getComputedStyle(element).getPropertyValue(property);
|
|
43
40
|
} else {
|
|
44
41
|
element.style.setProperty(
|
|
45
42
|
property,
|
|
46
|
-
isNumeric(value) && !cssNumber[property]
|
|
43
|
+
isNumeric(value) && !cssNumber[property]
|
|
44
|
+
? `${value}px`
|
|
45
|
+
: value || isNumber(value)
|
|
46
|
+
? value
|
|
47
|
+
: '',
|
|
47
48
|
priority
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
51
|
} else if (isArray(property)) {
|
|
51
|
-
const styles = getStyles(element);
|
|
52
52
|
const props = {};
|
|
53
53
|
for (const prop of property) {
|
|
54
|
-
props[prop] =
|
|
54
|
+
props[prop] = css(element, prop);
|
|
55
55
|
}
|
|
56
56
|
return props;
|
|
57
57
|
} else if (isObject(property)) {
|
|
@@ -62,19 +62,9 @@ export function css(element, property, value, priority = '') {
|
|
|
62
62
|
return elements[0];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
function getStyles(element, pseudoElt) {
|
|
66
|
-
return toWindow(element).getComputedStyle(element, pseudoElt);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function getStyle(element, property, pseudoElt) {
|
|
70
|
-
return getStyles(element, pseudoElt)[property];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
65
|
const propertyRe = /^\s*(["'])?(.*?)\1\s*$/;
|
|
74
|
-
export function getCssVar(name) {
|
|
75
|
-
return
|
|
76
|
-
.getPropertyValue(`--uk-${name}`)
|
|
77
|
-
.replace(propertyRe, '$2');
|
|
66
|
+
export function getCssVar(name, element = document.documentElement) {
|
|
67
|
+
return css(element, `--uk-${name}`).replace(propertyRe, '$2');
|
|
78
68
|
}
|
|
79
69
|
|
|
80
70
|
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
|
|
@@ -83,6 +73,10 @@ export const propName = memoize((name) => vendorPropName(name));
|
|
|
83
73
|
const cssPrefixes = ['webkit', 'moz'];
|
|
84
74
|
|
|
85
75
|
function vendorPropName(name) {
|
|
76
|
+
if (name[0] === '-') {
|
|
77
|
+
return name;
|
|
78
|
+
}
|
|
79
|
+
|
|
86
80
|
name = hyphenate(name);
|
|
87
81
|
|
|
88
82
|
const { style } = document.documentElement;
|