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

Function computeAutoPlacement

web/static/js/bootstrap.bundle.js:2182–2231  ·  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 {Ob

(placement, refRect, popper, reference, boundariesElement)

Source from the content-addressed store, hash-verified

2180 * @returns {Object} The data object, properly modified
2181 */
2182 function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
2183 var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
2184
2185 if (placement.indexOf('auto') === -1) {
2186 return placement;
2187 }
2188
2189 var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
2190
2191 var rects = {
2192 top: {
2193 width: boundaries.width,
2194 height: refRect.top - boundaries.top
2195 },
2196 right: {
2197 width: boundaries.right - refRect.right,
2198 height: boundaries.height
2199 },
2200 bottom: {
2201 width: boundaries.width,
2202 height: boundaries.bottom - refRect.bottom
2203 },
2204 left: {
2205 width: refRect.left - boundaries.left,
2206 height: boundaries.height
2207 }
2208 };
2209
2210 var sortedAreas = Object.keys(rects).map(function (key) {
2211 return _extends({
2212 key: key
2213 }, rects[key], {
2214 area: getArea(rects[key])
2215 });
2216 }).sort(function (a, b) {
2217 return b.area - a.area;
2218 });
2219
2220 var filteredAreas = sortedAreas.filter(function (_ref2) {
2221 var width = _ref2.width,
2222 height = _ref2.height;
2223 return width >= popper.clientWidth && height >= popper.clientHeight;
2224 });
2225
2226 var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
2227
2228 var variation = placement.split('-')[1];
2229
2230 return computedPlacement + (variation ? '-' + variation : '');
2231 }
2232
2233 /**
2234 * Get offsets to the reference element

Callers 2

updateFunction · 0.85
applyStyleOnLoadFunction · 0.85

Calls 2

getBoundariesFunction · 0.85
getAreaFunction · 0.85

Tested by

no test coverage detected