Raphael JS:如何删除事件?

问题描述

| 我使用Raphael .mouSEOver()和.mouSEOut()事件来突出显示SVG中的某些元素。 这可以正常工作,但是在单击元素后,我希望它停止突出显示。 在Raphael文档中,我发现:   要取消绑定事件,请使用带有“ un”前缀的相同方法名称,即element.unclick(f);。 但是我无法使它正常工作,而且我也不理解\'f \'参数。 这行不通,但是怎么办?
obj.click( function() {
  this.unmouSEOver();
});
    

解决方法

        好的,您要做的就是将处理函数传递给
unmouseover
请求:
// Creates canvas 320 × 200 at 10,50
var paper = Raphael(10,50,320,200);
// Creates circle at x = 50,y = 40,with radius 10
var circle = paper.circle(50,40,10);
// Sets the fill attribute of the circle to red (#f00)
circle.attr(\"fill\",\"#f00\");
// Sets the stroke attribute of the circle to white
circle.attr(\"stroke\",\"#fff\");

var mouseover = function (event) {
    this.attr({fill: \"yellow\"});
}
var mouseout = function (event) {
    this.attr({fill: \"red\"});
}

circle.hover(mouseover,mouseout);
circle.click(function (event) {
    this.attr({fill: \"blue\"});
    this.unmouseover(mouseover);
    this.unmouseout(mouseout);
});
http://jsfiddle.net/GexHj/1/ 那就是ѭ3的意思。您也可以使用
unhover()
circle.click(function (event) {
    this.attr({fill: \"blue\"});
    this.unhover(mouseover,mouseout);
});
http://jsfiddle.net/GexHj/2/