MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / getContentClientRect

Function getContentClientRect

scripts/magnify_image.js:1401–1417  ·  view source on GitHub ↗
(target, win = window)

Source from the content-addressed store, hash-verified

1399}
1400// prettier-ignore
1401function getContentClientRect(target, win = window) {
1402 let rect = target.getBoundingClientRect();
1403 let compStyle = win.getComputedStyle(target);
1404 let pFloat = parseFloat;
1405 let top = rect.top + pFloat(compStyle.paddingTop) + pFloat(compStyle.borderTopWidth);
1406 let right = rect.right - pFloat(compStyle.paddingRight) - pFloat(compStyle.borderRightWidth);
1407 let bottom = rect.bottom - pFloat(compStyle.paddingBottom) - pFloat(compStyle.borderBottomWidth);
1408 let left = rect.left + pFloat(compStyle.paddingLeft) + pFloat(compStyle.borderLeftWidth);
1409 return {
1410 top : top,
1411 right : right,
1412 bottom : bottom,
1413 left : left,
1414 width : right-left,
1415 height : bottom-top,
1416 };
1417}
1418function onDoublePress(key, callback, timeout = 500) {
1419 let timer = null;
1420 let clickCount = 0;

Callers 1

magnify_image.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected