Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RADIAL_EDGE && TREE_EDGE functions fail on missing node._parent (possible fix) #42

Open
NgMomentum opened this issue Feb 3, 2018 · 0 comments

Comments

@NgMomentum
Copy link

NgMomentum commented Feb 3, 2018

I had a problem with the RADIAL_EDGE && TREE_EDGE functions failing when the var node was presented without a ['_parent']. This might not be a typical case, as I'm new to using the latest version of ui-router (v1.0.14) and visualizer, and I might be implementing things differently (timing issues, etc). Anyway, the problem seemed to come from the "nodes.filter" part of the _this.nodeForState function returning a node for the value of node.name and state.name both being the undefined string (''). Not sure why I get this and other aren't, but the fix is relatively trivial, so here it is:

function TREE_EDGE(node, renderer) {
    var strokeWidth = renderer.baseStrokeWidth * renderer.zoom;
    var makeLinkPath = function (node) {
        var s = { x: node.animX, y: node.animY }; // statevisnode
        var p = {
			x: node._parent ? node._parent.animX : node.animX,
			y: node._parent ? node._parent.animY : node.animY
		}; // parent
        var yAvg = (s.y + p.y) / 2;
        return "M " + s.x + " " + s.y + " C " + s.x + " " + yAvg + ", " + p.x + " " + yAvg + ", " + p.x + " " + p.y;
    };
    return preact_1.h("path", { d: makeLinkPath(node), "stroke-width": strokeWidth, className: 'link' });
}

I just check for the existance of _parent in node first. My app worked fine thereafter, and the node._parent node seems to be updated in the next iteration anyway. I didin't see any difference in positioning from the demo available on the web. So, this is just a suggestion as I am no expert on ui-router and visualizer. Really like the way visualizer.js presents UI-Router states.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant