Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Open
beldaz opened this Issue · 6 comments

3 participants

@beldaz

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

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

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

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

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

Sorry, wrong, too many tabs open

@kucheruk kucheruk referenced this issue from a commit in metacommunications/raphael
@kucheruk kucheruk fix for arrow-end issues #471 and #506 08eaeef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.