MCPcopy Create free account
hub / github.com/shipshapecode/tether / getVisibleBounds

Function getVisibleBounds

src/js/utils/bounds.js:111–143  ·  view source on GitHub ↗
(body, target)

Source from the content-addressed store, hash-verified

109 * @return {{top: *, left: *, width: *, height: *}}
110 */
111export function getVisibleBounds(body, target) {
112 if (target === document.body) {
113 return { top: pageYOffset, left: pageXOffset, height: innerHeight, width: innerWidth };
114 } else {
115 const bounds = getBounds(body, target);
116
117 const out = {
118 height: bounds.height,
119 width: bounds.width,
120 top: bounds.top,
121 left: bounds.left
122 };
123
124 out.height = Math.min(out.height, bounds.height - (pageYOffset - bounds.top));
125 out.height = Math.min(out.height, bounds.height - ((bounds.top + bounds.height) - (pageYOffset + innerHeight)));
126 out.height = Math.min(innerHeight, out.height);
127 out.height -= 2;
128
129 out.width = Math.min(out.width, bounds.width - (pageXOffset - bounds.left));
130 out.width = Math.min(out.width, bounds.width - ((bounds.left + bounds.width) - (pageXOffset + innerWidth)));
131 out.width = Math.min(innerWidth, out.width);
132 out.width -= 2;
133
134 if (out.top < pageYOffset) {
135 out.top = pageYOffset;
136 }
137 if (out.left < pageXOffset) {
138 out.left = pageXOffset;
139 }
140
141 return out;
142 }
143}
144
145export function removeUtilElements(body) {
146 if (zeroElement && zeroElement?.parentNode === body) {

Callers 2

bounds.spec.jsFile · 0.90
getTargetBoundsMethod · 0.90

Calls 1

getBoundsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…