MCPcopy
hub / github.com/tdewolff/minify / getLayoutRect

Function getLayoutRect

_benchmarks/sample_echarts.js:16787–16883  ·  view source on GitHub ↗

* Parse position info.

(positionInfo, containerRect, margin)

Source from the content-addressed store, hash-verified

16785 */
16786
16787 function getLayoutRect(positionInfo, containerRect, margin) {
16788 margin = normalizeCssArray$1(margin || 0);
16789 var containerWidth = containerRect.width;
16790 var containerHeight = containerRect.height;
16791 var left = parsePercent$1(positionInfo.left, containerWidth);
16792 var top = parsePercent$1(positionInfo.top, containerHeight);
16793 var right = parsePercent$1(positionInfo.right, containerWidth);
16794 var bottom = parsePercent$1(positionInfo.bottom, containerHeight);
16795 var width = parsePercent$1(positionInfo.width, containerWidth);
16796 var height = parsePercent$1(positionInfo.height, containerHeight);
16797 var verticalMargin = margin[2] + margin[0];
16798 var horizontalMargin = margin[1] + margin[3];
16799 var aspect = positionInfo.aspect; // If width is not specified, calculate width from left and right
16800
16801 if (isNaN(width)) {
16802 width = containerWidth - right - horizontalMargin - left;
16803 }
16804
16805 if (isNaN(height)) {
16806 height = containerHeight - bottom - verticalMargin - top;
16807 }
16808
16809 if (aspect != null) {
16810 // If width and height are not given
16811 // 1. Graph should not exceeds the container
16812 // 2. Aspect must be keeped
16813 // 3. Graph should take the space as more as possible
16814 // FIXME
16815 // Margin is not considered, because there is no case that both
16816 // using margin and aspect so far.
16817 if (isNaN(width) && isNaN(height)) {
16818 if (aspect > containerWidth / containerHeight) {
16819 width = containerWidth * 0.8;
16820 } else {
16821 height = containerHeight * 0.8;
16822 }
16823 } // Calculate width or height with given aspect
16824
16825
16826 if (isNaN(width)) {
16827 width = aspect * height;
16828 }
16829
16830 if (isNaN(height)) {
16831 height = width / aspect;
16832 }
16833 } // If left is not specified, calculate left from right and width
16834
16835
16836 if (isNaN(left)) {
16837 left = containerWidth - right - width - horizontalMargin;
16838 }
16839
16840 if (isNaN(top)) {
16841 top = containerHeight - bottom - height - verticalMargin;
16842 } // Align left and top
16843
16844

Callers 11

positionElementFunction · 0.85
getViewRectFunction · 0.85
sample_echarts.jsFile · 0.85
resizeGeoFunction · 0.85
getViewRect$1Function · 0.85
getViewRect$2Function · 0.85
getViewRect$3Function · 0.85
getViewRect$4Function · 0.85
layout$3Function · 0.85
getViewRect$5Function · 0.85
getItemAlignFunction · 0.85

Calls 2

parsePercent$1Function · 0.85
isNaNFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…