Raphael JS事件未开火

Raphael JS events not firing

本文关键字:开火 事件 JS Raphael      更新时间:2023-09-26

我有一个Raphael.js图标,我正试图将一个click even监听器附加到该图标上。当我自动启动该函数(使用闭包括号())时,控制台日志是成功的。但是,在没有自动执行该函数的情况下,我无法启动该事件。转换是否存在将渲染路径放在页面其他位置的已知错误/问题?我在这里发表了大量评论,如果有人看到类似的问题,请发表。

              var paper3 = Raphael($("#mail").get(0), 175, 75);
              var iconPath3 = paper3.path(iconPath);
              iconPath3.transform("s1.3, t0,5");
              iconPath3.attr("fill","fff");
              iconPath3.click(function(e) {
                  console.log("Test");
              });

您可以尝试在jQuery对象中包装iconPath3:

$(iconPath3).click(function(e){
     console.log("Logging event: ", e);
});

此外,您是否尝试过使用JavaScript对象设置填充:

iconPath3.attr({fill: '#fff'});

希望能有所帮助。