本文介绍了Raphael JS:如何去除事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Raphael.mouseover()和.mouseout()事件来突出显示我的SVG中的某些元素。
这工作正常,但是点击一个元素后,我想要停止突出显示。
I use the Raphael .mouseover() and .mouseout() events to highlight some elements in my SVG.This works fine, but after I click on an element, I want it to stop highlighting.
在我发现:
但我无法让这个工作我也不明白'f'参数。
but I can't get this to work and I also don't understand the 'f' parameter.
这不起作用,但是什么是
This doesn't work , but what does??
obj.click( function() {
this.unmouseover();
});
推荐答案
好的,你要做的是传递处理程序功能到 unmouseover
请求:
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);
});
这就是 f
。您也可以使用 unhover()
:
That's what f
is about. You can also use unhover()
:
circle.click(function (event) {
this.attr({fill: "blue"});
this.unhover(mouseover, mouseout);
});
这篇关于Raphael JS:如何去除事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!