悬停在 raphaeljs 中不起作用
我目前正在将匿名函数应用于悬停事件,该函数在内部调用全局函数:
GridInterface.HexGrid.TileGlobal = {
hoverIn: function(obj) {
var self = obj;
self.tile.attr({ fill: '#c7c7c7', stroke : '#000' });
self.tile.toFront();
self.label.toFront();
self.label.attr({ fill : '#000' });
},
hoverOut: function(obj) {
var self = obj;
self.tile.attr({ fill : '#d0d1ff', stroke : '#aaa' });
self.label.attr({ fill: '#999' });
}
}
然后我只需
.hover(function() {
GridInterface.HexGrid.TileGlobal.hoverIn(self);
}, function() {
GridInterface.HexGrid.TileGlobal.hoverOut(self);
}
)
在对象上调用: 。但是,当我将其切换为悬停时,该事件不会被删除。我认为这是因为它是一个不同的匿名函数。关于如何修复有什么想法吗?
I'm currently applying anonymous functions to a hover event, that call global functions inside:
GridInterface.HexGrid.TileGlobal = {
hoverIn: function(obj) {
var self = obj;
self.tile.attr({ fill: '#c7c7c7', stroke : '#000' });
self.tile.toFront();
self.label.toFront();
self.label.attr({ fill : '#000' });
},
hoverOut: function(obj) {
var self = obj;
self.tile.attr({ fill : '#d0d1ff', stroke : '#aaa' });
self.label.attr({ fill: '#999' });
}
}
Then i simply call:
.hover(function() {
GridInterface.HexGrid.TileGlobal.hoverIn(self);
}, function() {
GridInterface.HexGrid.TileGlobal.hoverOut(self);
}
)
on the object. However, when i switch that to unhover, the event is not removed. I think it's because it's a different anonymous function. Any ideas on how to fix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
然后在其他地方我调用:
Tile 是上述函数的对象实例。
Then elsewhere i call:
Tile being an object instance of that above function.
也许不是通过 raphäel 事件处理来解决问题,而是通过您选择的库来解决问题,即 jQuery: $(circle.node).click(...)
就像您可以按需添加事件/删除事件一样。
Maybe solve the problem not with the raphäel event handling but with a library of your choice, ie jQuery: $(circle.node).click(…)
like that you can addEvent / removeEvent on demand.