MCPcopy Create free account
hub / github.com/breck7/scroll / apportion

Function apportion

external/.d3.js:13999–14036  ·  view source on GitHub ↗
(v, w, ancestor)

Source from the content-addressed store, hash-verified

13997 // SUBTREE to shift the subtree and prepare the shifts of smaller subtrees.
13998 // Finally, we add a new thread (if necessary).
13999 function apportion(v, w, ancestor) {
14000 if (w) {
14001 var vip = v,
14002 vop = v,
14003 vim = w,
14004 vom = vip.parent.children[0],
14005 sip = vip.m,
14006 sop = vop.m,
14007 sim = vim.m,
14008 som = vom.m,
14009 shift;
14010 while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {
14011 vom = nextLeft(vom);
14012 vop = nextRight(vop);
14013 vop.a = v;
14014 shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
14015 if (shift > 0) {
14016 moveSubtree(nextAncestor(vim, v, ancestor), v, shift);
14017 sip += shift;
14018 sop += shift;
14019 }
14020 sim += vim.m;
14021 sip += vip.m;
14022 som += vom.m;
14023 sop += vop.m;
14024 }
14025 if (vim && !nextRight(vop)) {
14026 vop.t = vim;
14027 vop.m += sim - sop;
14028 }
14029 if (vip && !nextLeft(vom)) {
14030 vom.t = vip;
14031 vom.m += sip - som;
14032 ancestor = v;
14033 }
14034 }
14035 return ancestor;
14036 }
14037
14038 function sizeNode(node) {
14039 node.x *= dx;

Callers 1

firstWalkFunction · 0.85

Calls 4

nextRightFunction · 0.85
nextLeftFunction · 0.85
moveSubtreeFunction · 0.85
nextAncestorFunction · 0.85

Tested by

no test coverage detected