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

Function computeAutoPlacement

app/src/static/js/react-bootstrap.js:3660–3703  ·  view source on GitHub ↗

* Utility used to transform the `auto` placement to the placement with more * available space. * @method * @memberof Popper.Utils * @argument {Object} data - The data object generated by update method * @argument {Object} options - Modifiers configuration and options * @returns {Object} The da

(placement, refRect, popper, reference, boundariesElement)

Source from the content-addressed store, hash-verified

3658
3659
3660function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
3661 var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
3662
3663 if (placement.indexOf('auto') === -1) {
3664 return placement;
3665 }
3666
3667 var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
3668 var rects = {
3669 top: {
3670 width: boundaries.width,
3671 height: refRect.top - boundaries.top
3672 },
3673 right: {
3674 width: boundaries.right - refRect.right,
3675 height: boundaries.height
3676 },
3677 bottom: {
3678 width: boundaries.width,
3679 height: boundaries.bottom - refRect.bottom
3680 },
3681 left: {
3682 width: refRect.left - boundaries.left,
3683 height: boundaries.height
3684 }
3685 };
3686 var sortedAreas = Object.keys(rects).map(function (key) {
3687 return _extends({
3688 key: key
3689 }, rects[key], {
3690 area: getArea(rects[key])
3691 });
3692 }).sort(function (a, b) {
3693 return b.area - a.area;
3694 });
3695 var filteredAreas = sortedAreas.filter(function (_ref2) {
3696 var width = _ref2.width,
3697 height = _ref2.height;
3698 return width >= popper.clientWidth && height >= popper.clientHeight;
3699 });
3700 var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
3701 var variation = placement.split('-')[1];
3702 return computedPlacement + (variation ? '-' + variation : '');
3703}
3704/**
3705 * Get offsets to the reference element
3706 * @method

Callers 2

updateFunction · 0.85
applyStyleOnLoadFunction · 0.85

Calls 3

getBoundariesFunction · 0.85
_extendsFunction · 0.85
getAreaFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…