aleman 1.12.2 → 1.12.4
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 +10 -0
- package/menu/addons/context-menu.js +1 -1
- package/menu/addons/set-position/calculate.js +28 -0
- package/menu/addons/{set-position.js → set-position/set-position.js} +12 -27
- package/menu/hydrate-menu.js +1 -1
- package/menu/importmap.js +1 -1
- package/menu/rules/build-menu/index.js +2 -3
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function calculate(event, sizes) {
|
|
2
|
+
let {clientX, clientY} = event;
|
|
3
|
+
const {
|
|
4
|
+
heightMenu,
|
|
5
|
+
widthMenu,
|
|
6
|
+
innerHeight,
|
|
7
|
+
innerWidth,
|
|
8
|
+
} = sizes;
|
|
9
|
+
|
|
10
|
+
if (innerWidth < widthMenu + clientX + clientX / 2) {
|
|
11
|
+
clientX -= widthMenu;
|
|
12
|
+
|
|
13
|
+
if (clientX < 0)
|
|
14
|
+
clientX = 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (innerHeight < heightMenu + clientY) {
|
|
18
|
+
clientY -= heightMenu;
|
|
19
|
+
|
|
20
|
+
if (clientY < 0)
|
|
21
|
+
clientY = 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
x: clientX,
|
|
26
|
+
y: clientY - 14,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import {calculate} from './calculate.js';
|
|
2
|
+
|
|
1
3
|
export const setPosition = (name, event) => {
|
|
2
4
|
const element = document.querySelector(`[data-name="${name}"]`);
|
|
3
|
-
const
|
|
5
|
+
const heightMenu = getMenuHeight(element);
|
|
6
|
+
const widthMenu = getMenuWidth(element);
|
|
7
|
+
const {innerHeight, innerWidth} = window;
|
|
8
|
+
|
|
9
|
+
const {x, y} = calculate(event, {
|
|
10
|
+
heightMenu,
|
|
11
|
+
widthMenu,
|
|
12
|
+
innerWidth,
|
|
13
|
+
innerHeight,
|
|
14
|
+
});
|
|
4
15
|
|
|
5
16
|
element.style.left = `${x}px`;
|
|
6
17
|
element.style.top = `${y}px`;
|
|
@@ -13,32 +24,6 @@ export const setPosition = (name, event) => {
|
|
|
13
24
|
};
|
|
14
25
|
};
|
|
15
26
|
|
|
16
|
-
function calculate(element, {clientX, clientY}) {
|
|
17
|
-
const heightMenu = getMenuHeight(element);
|
|
18
|
-
const widthMenu = getMenuWidth(element);
|
|
19
|
-
const heightInner = window.innerHeight;
|
|
20
|
-
const widthInner = window.innerWidth;
|
|
21
|
-
|
|
22
|
-
if (widthInner < widthMenu + clientX) {
|
|
23
|
-
clientX -= widthMenu;
|
|
24
|
-
|
|
25
|
-
if (clientX < 0)
|
|
26
|
-
clientX = 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (heightInner < heightMenu + clientY) {
|
|
30
|
-
clientY -= heightMenu;
|
|
31
|
-
|
|
32
|
-
if (clientY < 0)
|
|
33
|
-
clientY = 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
x: clientX,
|
|
38
|
-
y: clientY - 14,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
27
|
function getMenuHeight(element) {
|
|
43
28
|
const {height} = getComputedStyle(element);
|
|
44
29
|
return parseInt(height, 10);
|
package/menu/hydrate-menu.js
CHANGED
|
@@ -6,7 +6,7 @@ import {createMouseEnter} from './addons/mouse-enter.js';
|
|
|
6
6
|
import {createItemClick} from './addons/item-click.js';
|
|
7
7
|
import * as click from './addons/click.js';
|
|
8
8
|
import {createContextMenu} from './addons/context-menu.js';
|
|
9
|
-
import {setPosition} from './addons/set-position.js';
|
|
9
|
+
import {setPosition} from './addons/set-position/set-position.js';
|
|
10
10
|
|
|
11
11
|
const {assign} = Object;
|
|
12
12
|
|
package/menu/importmap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const importmap = {
|
|
2
2
|
imports: {
|
|
3
|
-
'putout': 'https://esm.sh/@putout/bundle@4.7.
|
|
3
|
+
'putout': 'https://esm.sh/@putout/bundle@4.7.3',
|
|
4
4
|
'@putout/processor-html': 'https://esm.sh/@putout/processor-html',
|
|
5
5
|
'fullstore': 'https://esm.sh/fullstore',
|
|
6
6
|
'jessy': 'https://esm.sh/jessy',
|
|
@@ -8,7 +8,6 @@ const {
|
|
|
8
8
|
|
|
9
9
|
const {entries} = Object;
|
|
10
10
|
|
|
11
|
-
const noop = () => {};
|
|
12
11
|
const isObject = (a) => a && typeof a === 'object';
|
|
13
12
|
|
|
14
13
|
export const report = () => `Build menu`;
|
|
@@ -22,8 +21,8 @@ const createMenu = template(`
|
|
|
22
21
|
`);
|
|
23
22
|
|
|
24
23
|
const DefaultMenu = {
|
|
25
|
-
hello:
|
|
26
|
-
world:
|
|
24
|
+
hello: null,
|
|
25
|
+
world: null,
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
export const fix = ({path, menu, icon, name = ''}) => {
|