SVG line markers not updating when line moves in IE10?

泄露秘密 提交于 2019-11-27 19:25:39

This is a quick way of doing it, that works well. I have not noticed any flickering or performance related issues.

Simply re-add the svg node in it's original place:

if (navigator.appVersion.indexOf("MSIE 10") != -1) {
    svgNode.parentNode.insertBefore(svgNode, svgNode);
}

Of course, you could use any browser sniffing of choice..

I want to elaborate a little on the amazing answer given by @ChristianLund and how I used it successfully in my code

In my force animation, I have a tick function that looks like this:

force.on("tick", function() {
  ...
});

I also hold all of my graph links inside the link variable, defined like so:

var link = svg.selectAll(".link").data(links).enter() ...

Now, to implement the magic suggested by Christian, I've added this line in the beginning of my tick function:

force.on("tick", function() {
  link.each(function() {this.parentNode.insertBefore(this, this); });
  ...
});

This seems to fix the IE 10 problems... of course it's recommended to add this patch only on IE 10

In ie10/11, I found that the line does not move when it with marker-start/marker-end atrribute, I tried to remove those atrributes in your example, and it works. So the idea is remove the atrributes before set the x/y, then reset the atrributes after all jobs done.

You may try this hack:

$("#button4").click(function () {
$("#line1")[0].setAttributeNS(null, "x1", 50);
$("#line1")[0].setAttributeNS(null, "y1", 50);
$("#line1")[0].setAttributeNS(null, "x2", 150);
$("#line1")[0].setAttributeNS(null, "y2", 50);
var oldAttValueDisplay = $("#line1")[0].getAttributeNS(null, "display");
$("#line1")[0].setAttributeNS(null, "display", "none");
setTimeout(function() {$("#line1")[0].setAttributeNS(null, "display", oldAttValueDisplay);}, 0);
// static: setTimeout(function() {$("#line1")[0].setAttributeNS(null, "display", "block");}, 0);    

});

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!