javascript - SVG : how to properly handle mouseover and mouseout event? - Stack Overflow

I'm using Raphael js framework to create interactive svg image on client: var paper = Raphael(do

I'm using Raphael js framework to create interactive svg image on client:

var paper = Raphael(document.getElementById("svgcontainer"));
var path = paper.path("M0,0 L150,0 L150,150, L0,150 Z");

path.attr({fill: 'red'});

var text = paper.text(40,20, "some text");

path.mouseover(function(){this.attr({fill: 'green'})});
path.mouseout(function(){this.attr({fill: 'red'})});

Please look at jsfiddle example /

If the user moves the mouse over the text inside the path element, the path element will trigger mouseout event. How to prevent triggering of mouseout event on path element when user moves mouse to text element?

I'm using Raphael js framework to create interactive svg image on client:

var paper = Raphael(document.getElementById("svgcontainer"));
var path = paper.path("M0,0 L150,0 L150,150, L0,150 Z");

path.attr({fill: 'red'});

var text = paper.text(40,20, "some text");

path.mouseover(function(){this.attr({fill: 'green'})});
path.mouseout(function(){this.attr({fill: 'red'})});

Please look at jsfiddle example http://jsfiddle/6BtUk/9/

If the user moves the mouse over the text inside the path element, the path element will trigger mouseout event. How to prevent triggering of mouseout event on path element when user moves mouse to text element?

Share Improve this question edited Jan 3, 2012 at 20:30 puk 16.8k31 gold badges126 silver badges206 bronze badges asked Jan 3, 2012 at 19:47 AndreiAndrei 4,2173 gold badges29 silver badges32 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

I haven't worked with Raphael but it looks like you can try using Set to group your label and the rectangle and attach the event handler to the set.

jsfiddle

Here is another question that is similar to yours

Raphael JS : mouseover/mouseout - problem with text-labels

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745575999a4633964.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信