MCPcopy
hub / github.com/deepch/RTSPtoWebRTC / getPopperOffsets

Function getPopperOffsets

web/static/js/bootstrap.bundle.js:2293–2320  ·  view source on GitHub ↗

* Get offsets to the popper * @method * @memberof Popper.Utils * @param {Object} position - CSS position the Popper will get applied * @param {HTMLElement} popper - the popper element * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this) *

(popper, referenceOffsets, placement)

Source from the content-addressed store, hash-verified

2291 * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
2292 */
2293 function getPopperOffsets(popper, referenceOffsets, placement) {
2294 placement = placement.split('-')[0];
2295
2296 // Get popper node sizes
2297 var popperRect = getOuterSizes(popper);
2298
2299 // Add position, width and height to our offsets object
2300 var popperOffsets = {
2301 width: popperRect.width,
2302 height: popperRect.height
2303 };
2304
2305 // depending by the popper placement we have to compute its offsets slightly differently
2306 var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
2307 var mainSide = isHoriz ? 'top' : 'left';
2308 var secondarySide = isHoriz ? 'left' : 'top';
2309 var measurement = isHoriz ? 'height' : 'width';
2310 var secondaryMeasurement = !isHoriz ? 'height' : 'width';
2311
2312 popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
2313 if (placement === secondarySide) {
2314 popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
2315 } else {
2316 popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
2317 }
2318
2319 return popperOffsets;
2320 }
2321
2322 /**
2323 * Mimics the `find` method of Array

Callers 2

updateFunction · 0.85
flipFunction · 0.85

Calls 2

getOuterSizesFunction · 0.85
getOppositePlacementFunction · 0.85

Tested by

no test coverage detected