Raphael JS : how to remove events?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 12:22:08

Ok, what you have to do is pass the handler function to the unmouseover request:

// 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/

That's what f is about. You can also use unhover():

circle.click(function (event) {
    this.attr({fill: "blue"});
    this.unhover(mouseover, mouseout);
});

http://jsfiddle.net/GexHj/2/

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