MCPcopy Index your code
hub / github.com/python/cpython / calculateMenuPosition

Function calculateMenuPosition

Lib/profiling/sampling/_heatmap_assets/heatmap.js:36–52  ·  view source on GitHub ↗
(buttonRect, menuWidth, menuHeight)

Source from the content-addressed store, hash-verified

34}
35
36function calculateMenuPosition(buttonRect, menuWidth, menuHeight) {
37 const viewport = { width: window.innerWidth, height: window.innerHeight };
38 const scroll = {
39 x: window.pageXOffset || document.documentElement.scrollLeft,
40 y: window.pageYOffset || document.documentElement.scrollTop
41 };
42
43 const left = buttonRect.right + menuWidth + 10 < viewport.width
44 ? buttonRect.right + scroll.x + 10
45 : Math.max(scroll.x + 10, buttonRect.left + scroll.x - menuWidth - 10);
46
47 const top = buttonRect.bottom + menuHeight + 10 < viewport.height
48 ? buttonRect.bottom + scroll.y + 5
49 : Math.max(scroll.y + 10, buttonRect.top + scroll.y - menuHeight - 10);
50
51 return { left, top };
52}
53
54// ============================================================================
55// Menu Management

Callers 1

showNavigationMenuFunction · 0.85

Calls 1

maxMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…