MCPcopy Index your code
hub / github.com/docker/getting-started / getPopperOffsets

Function getPopperOffsets

app/src/static/js/react-bootstrap.js:3773–3797  ·  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) * @param {Str

(popper, referenceOffsets, placement)

Source from the content-addressed store, hash-verified

3771
3772
3773function getPopperOffsets(popper, referenceOffsets, placement) {
3774 placement = placement.split('-')[0]; // Get popper node sizes
3775
3776 var popperRect = getOuterSizes(popper); // Add position, width and height to our offsets object
3777
3778 var popperOffsets = {
3779 width: popperRect.width,
3780 height: popperRect.height
3781 }; // depending by the popper placement we have to compute its offsets slightly differently
3782
3783 var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
3784 var mainSide = isHoriz ? 'top' : 'left';
3785 var secondarySide = isHoriz ? 'left' : 'top';
3786 var measurement = isHoriz ? 'height' : 'width';
3787 var secondaryMeasurement = !isHoriz ? 'height' : 'width';
3788 popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
3789
3790 if (placement === secondarySide) {
3791 popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
3792 } else {
3793 popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
3794 }
3795
3796 return popperOffsets;
3797}
3798/**
3799 * Mimics the `find` method of Array
3800 * @method

Callers 2

updateFunction · 0.85
flipFunction · 0.85

Calls 2

getOuterSizesFunction · 0.85
getOppositePlacementFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…