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

Function positionElement

_benchmarks/sample_echarts.js:16923–16968  ·  view source on GitHub ↗

* Position a zr element in viewport * Group position is specified by either * {left, top}, {right, bottom} * If all properties exists, right and bottom will be igonred. * * Logic: * 1. Scale (against origin point in parent coord) * 2. Rotate (against ori

(el, positionInfo, containerRect, margin, opt)

Source from the content-addressed store, hash-verified

16921 */
16922
16923 function positionElement(el, positionInfo, containerRect, margin, opt) {
16924 var h = !opt || !opt.hv || opt.hv[0];
16925 var v = !opt || !opt.hv || opt.hv[1];
16926 var boundingMode = opt && opt.boundingMode || 'all';
16927
16928 if (!h && !v) {
16929 return;
16930 }
16931
16932 var rect;
16933
16934 if (boundingMode === 'raw') {
16935 rect = el.type === 'group' ? new BoundingRect(0, 0, +positionInfo.width || 0, +positionInfo.height || 0) : el.getBoundingRect();
16936 } else {
16937 rect = el.getBoundingRect();
16938
16939 if (el.needLocalTransform()) {
16940 var transform = el.getLocalTransform(); // Notice: raw rect may be inner object of el,
16941 // which should not be modified.
16942
16943 rect = rect.clone();
16944 rect.applyTransform(transform);
16945 }
16946 } // The real width and height can not be specified but calculated by the given el.
16947
16948
16949 var layoutRect = getLayoutRect(defaults({
16950 width: rect.width,
16951 height: rect.height
16952 }, positionInfo), containerRect, margin); // Because 'tranlate' is the last step in transform
16953 // (see zrender/core/Transformable#getLocalTransform),
16954 // we can just only modify el.position to get final result.
16955
16956 var dx = h ? layoutRect.x - rect.x : 0;
16957 var dy = v ? layoutRect.y - rect.y : 0;
16958
16959 if (boundingMode === 'raw') {
16960 el.x = dx;
16961 el.y = dy;
16962 } else {
16963 el.x += dx;
16964 el.y += dy;
16965 }
16966
16967 el.markRedraw();
16968 }
16969 /**
16970 * @param option Contains some of the properties in HV_NAMES.
16971 * @param hvIdx 0: horizontal; 1: vertical.

Callers 2

sample_echarts.jsFile · 0.85
layout$3Function · 0.85

Calls 2

getLayoutRectFunction · 0.85
defaultsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…