diff --git a/OZprivate/rawJS/OZTreeModule/src/position_helper.js b/OZprivate/rawJS/OZTreeModule/src/position_helper.js index bd77a234..9290d4a0 100755 --- a/OZprivate/rawJS/OZTreeModule/src/position_helper.js +++ b/OZprivate/rawJS/OZTreeModule/src/position_helper.js @@ -381,6 +381,9 @@ function reanchor_at_node(node, root_node) { // Set graphref false everywhere deanchor(root_node); + // Anchor to this node + tree_state.anchor_node = node; // NB: Only saved for debugging purposes + // Walk up tree from (node), setting graphref while (node.upnode) { node.graphref = true; @@ -391,16 +394,25 @@ function reanchor_at_node(node, root_node) { } /** - * Walk tree, anchoring to the first node on-screen that has 2.2 < node.rvar < 22000 + * Walk tree, anchoring to the first node that is both on screen and of a reasonable size * (i.e. set graphref on this node and it's ancestors) + * + * Reasonable size here means we should ignore high-up nodes whose bounding boxes encompass half of + * insects in a balanced tree (e.g.) + * + * For debugging, you can draw the current anchor node with: + * onezoom.config.debug_bounding_box = (node => node === onezoom.tree_state.anchor_node ? 0x03 : 0) + * ...or add a browser watch condition of: + * onezoom.tree_state.anchored_node + ' ' + onezoom.tree_state.anchored_node.rvar */ function reanchor(node) { // If this node (or it's desendents) aren't visible, don't bother if (!node.dvar) return; node.graphref = true; - if (node.gvar || !node.has_child || (node.rvar > 2.2 && node.rvar < 22000)) { + if (!node.has_child || node.gvar && (node.rvar > 1 && node.rvar < 2200)) { // Anchor to this node + tree_state.anchor_node = node; // NB: Only saved for debugging purposes tree_state.xp = node.xvar; tree_state.yp = node.yvar; tree_state.ws = node.rvar / 220;