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

Removed arrows aren't removed when other arrows present #506

Open
beldaz opened this issue Jan 28, 2012 · 6 comments
Open

Removed arrows aren't removed when other arrows present #506

beldaz opened this issue Jan 28, 2012 · 6 comments

Comments

@beldaz
Copy link

beldaz commented Jan 28, 2012

Possibly related to #471.
This works as expected, with no arrow displayed:

var paper = Raphael(0, 0, 400, 300);
paper.path("M0 0L200 200").attr({
    "stroke-width": 5,
    "stroke": "blue",
    "arrow-end": "block-wide-long"
}).attr("arrow-end","none");

However, when another arrow is used elsewhere the arrow remains displayed:

var paper = Raphael(0, 0, 400, 300);
paper.path("M200 0L0 200").attr({
    "stroke-width": 5,
    "stroke": "blue",
    "arrow-end": "block-wide-long"
});
paper.path("M0 0L200 200").attr({
    "stroke-width": 5,
    "stroke": "blue",
    "arrow-end": "block-wide-long"
}).attr("arrow-end","none");
@beldaz
Copy link
Author

beldaz commented Jan 30, 2012

Closer inspection of the SVG generated reveals that calling path.attr("arrow-end","none") does not actually remove the marker: it changes the path length and reduces the reference count for the marker. If the reference count goes to zero no marker is defined, but path still calls a reference to it.

@beldaz
Copy link
Author

beldaz commented Jan 31, 2012

I can patch this problem by replacing (in raphael.js 2.0.1) line 3665 from

o._.arrows[se + "Path"] && $(node, {d: Raphael.getSubpath(attrs.path, from, to)});

to

if(o._.arrows[se + "Path"]) {
    attr = {};
    attr["marker-" + se] = "none";
    attr.d=Raphael.getSubpath(attrs.path, from, to);
    $(node, attr);
}

Here I update the value for attribute "marker-end" (or "marker-start") to "none". I would interested to know whether there is a way to explicitly remove an attribute rather than change its value.

@khayredinov
Copy link

You can add color to pathId, but when animation begin arrow may disappear
var pathId = "raphael-marker-" + type, markerId = "raphael-marker-"+ se + type + w + h;

@beldaz
Copy link
Author

beldaz commented Feb 2, 2012

khayredinov: you're talking about issue #471, right? It's actually unrelated to this issue. I recommend you re-post your comment in that issue instead.

@khayredinov
Copy link

Sorry, wrong, too many tabs open

@jberryman
Copy link

#525

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

3 participants