MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / clampMenuPosition

Function clampMenuPosition

src/cm/touchSelectionMenu.js:60–74  ·  view source on GitHub ↗
(menuRect, containerRect)

Source from the content-addressed store, hash-verified

58 * @returns {{left:number, top:number}}
59 */
60export function clampMenuPosition(menuRect, containerRect) {
61 const maxLeft = Math.max(
62 containerRect.left + MENU_MARGIN,
63 containerRect.left + containerRect.width - menuRect.width - MENU_MARGIN,
64 );
65 const maxTop = Math.max(
66 containerRect.top + MENU_MARGIN,
67 containerRect.top + containerRect.height - menuRect.height - MENU_MARGIN,
68 );
69
70 return {
71 left: clamp(menuRect.left, containerRect.left + MENU_MARGIN, maxLeft),
72 top: clamp(menuRect.top, containerRect.top + MENU_MARGIN, maxTop),
73 };
74}
75
76/**
77 * Filter menu items using Ace-compatible rules.

Callers 1

#showMenuMethod · 0.85

Calls 1

clampFunction · 0.85

Tested by

no test coverage detected