MCPcopy Index your code
hub / github.com/SortableJS/Sortable / getRect

Function getRect

modular/sortable.core.esm.js:249–312  ·  view source on GitHub ↗

* Returns the "bounding client rect" of given element * @param {HTMLElement} el The element whose boundingClientRect is wanted * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container * @param

(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container)

Source from the content-addressed store, hash-verified

247 * @return {Object} The boundingClientRect of el, with specified adjustments
248 */
249function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
250 if (!el.getBoundingClientRect && el !== window) return;
251 var elRect, top, left, bottom, right, height, width;
252 if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
253 elRect = el.getBoundingClientRect();
254 top = elRect.top;
255 left = elRect.left;
256 bottom = elRect.bottom;
257 right = elRect.right;
258 height = elRect.height;
259 width = elRect.width;
260 } else {
261 top = 0;
262 left = 0;
263 bottom = window.innerHeight;
264 right = window.innerWidth;
265 height = window.innerHeight;
266 width = window.innerWidth;
267 }
268 if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
269 // Adjust for translate()
270 container = container || el.parentNode;
271
272 // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
273 // Not needed on <= IE11
274 if (!IE11OrLess) {
275 do {
276 if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
277 var containerRect = container.getBoundingClientRect();
278
279 // Set relative to edges of padding box of container
280 top -= containerRect.top + parseInt(css(container, 'border-top-width'));
281 left -= containerRect.left + parseInt(css(container, 'border-left-width'));
282 bottom = top + elRect.height;
283 right = left + elRect.width;
284 break;
285 }
286 /* jshint boss:true */
287 } while (container = container.parentNode);
288 }
289 }
290 if (undoScale && el !== window) {
291 // Adjust for scale()
292 var elMatrix = matrix(container || el),
293 scaleX = elMatrix && elMatrix.a,
294 scaleY = elMatrix && elMatrix.d;
295 if (elMatrix) {
296 top /= scaleY;
297 left /= scaleX;
298 width /= scaleX;
299 height /= scaleY;
300 bottom = top + height;
301 right = left + width;
302 }
303 }
304 return {
305 top: top,
306 left: left,

Callers 11

isScrolledPastFunction · 0.70
AnimationStateManagerFunction · 0.70
_detectDirectionFunction · 0.70
dragOverEventFunction · 0.70
_onMoveFunction · 0.70
_ghostIsFirstFunction · 0.70
_ghostIsLastFunction · 0.70
MultiDragPluginFunction · 0.70

Calls 3

cssFunction · 0.70
matrixFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…