aleman 1.12.3 → 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 CHANGED
@@ -1,3 +1,8 @@
1
+ 2025.09.16, v1.12.4
2
+
3
+ fix:
4
+ - 870da2e aleman: menu: addons: set-position: clientX / 2
5
+
1
6
  2025.09.15, v1.12.3
2
7
 
3
8
  fix:
@@ -1,4 +1,4 @@
1
- import {setPosition} from './set-position.js';
1
+ import {setPosition} from './set-position/set-position.js';
2
2
 
3
3
  export const createContextMenu = (name) => ({
4
4
  name,
@@ -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 {x, y} = calculate(element, event);
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);
@@ -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
 
@@ -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: noop,
26
- world: noop,
24
+ hello: null,
25
+ world: null,
27
26
  };
28
27
 
29
28
  export const fix = ({path, menu, icon, name = ''}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aleman",
3
- "version": "1.12.3",
3
+ "version": "1.12.4",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",