Dyl*_*lan 6 events mouseover raphael
我使用Raphael .mouseover()和.mouseout()事件来突出显示我的SVG中的一些元素.这工作正常,但在我点击一个元素后,我希望它停止突出显示.
在Raphael文档中,我发现:
要取消绑定事件,请使用带有"un"前缀的相同方法名称,即element.unclick(f);
但我不能让这个工作,我也不明白'f'参数.
这不起作用,但是什么呢?
obj.click( function() {
this.unmouseover();
});
Run Code Online (Sandbox Code Playgroud)
好的,你要做的是将处理函数传递给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);
});
Run Code Online (Sandbox Code Playgroud)
这f是关于什么的.您还可以使用unhover():
circle.click(function (event) {
this.attr({fill: "blue"});
this.unhover(mouseover, mouseout);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6161 次 |
| 最近记录: |