MCPcopy Create free account
hub / github.com/hoothin/UserScripts / getContentClientRect

Function getContentClientRect

FlashViewer-HTML5 Video/flashViewer.user.js:232–250  ·  view source on GitHub ↗
(elem)

Source from the content-addressed store, hash-verified

230
231 //获取内容区域到版边的距离
232 function getContentClientRect(elem) {
233 var rect = elem.getBoundingClientRect();
234 var compStyle = getComputedStyle(elem);
235
236 var top = rect.top + parseFloat(compStyle.paddingTop) + parseFloat(compStyle.borderTopWidth);
237 var left = rect.left + parseFloat(compStyle.paddingLeft) + parseFloat(compStyle.borderLeftWidth);
238
239 var right = rect.right - parseFloat(compStyle.paddingRight) - parseFloat(compStyle.borderRightWidth);
240 var bottom = rect.bottom - parseFloat(compStyle.paddingBottom) - parseFloat(compStyle.borderBottomWidth);
241
242 return {
243 top: top,
244 right: right,
245 bottom: bottom,
246 left: left,
247 width: right - left,
248 height: bottom - top,
249 };
250 };
251
252
253 var escapeHTMLPolicy;

Callers 1

contentScriptFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected