javascript - SVG: Moving mouse to <image> element triggers mouseout event of parent <g> element (d3.js) -


i have <g> element <rect> , <image> inside. <g> has mouseout event listener. problem when move mouse rect image (within same g), mouseout event triggered (followed 'mouseover').

here's example. (and jsfiddle)

var x = 120;  var g = d3.select("svg")     .append("g")     .on('mouseover', function() {         d3.select(this).append("text").text("mouseover").attr('transform','translate(0,'+x+')');         x+=20;     })     .on('mouseout', function() {         d3.select(this).append("text").text("mouseout").attr('transform','translate(0,'+x+')');           x+=20;       })  g.append("rect")     .attr('width', 100)     .attr('height', 100)     .style('fill', 'lightgreen')  g.append('image')     .attr("width", 30)     .attr("height", 30)     .attr("x", 35)     .attr("y", 35)     .attr("xlink:href","https://www.gravatar.com/avatar/f70adb32032d39add2559c2609a90d03?s=128&d=identicon&r=pg") 

how prevent mouseout event triggering?

when use mouseout , mouseover on parent container, events when mouse moves between descendant elements. if want hear mouse enters or leaves parent, use mouseenter , mouseleave instead.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -