有人可以为Raphael JS事件提供一些代码示例

Someone can provide some code example for Raphael JS events?

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

我不知道如何使用Raphael JS事件。

我需要一些例子。我看到文档和一个函数必须传递,但没有工作。

有人可以提供一些例子,如何获得鼠标的位置点击在画布上?

EDIT:我在Element的文档事件中看到。这对Paper有用吗?如何为Paper创建mousedown()事件

clickEvent = function(){
    alert("Hello World!");
}
paper = Raphael(...);
paper.raphael.click(clickEvent);
p.mouseover(function () {
   p.stop().animate({transform: "s1.1 1.1 " + cx + " " + cy}, ms, "elastic");
   txt.stop().animate({opacity: 1}, ms, "elastic");
}).mouseout(function () {
   p.stop().animate({transform: ""}, ms, "elastic");
   txt.stop().animate({opacity: 0}, ms);
});

查看Raphael示例中的源代码。

下面是另一个带有click事件的例子:

movers[2].click(function () {
  this.cx = this.cx || 300;
  this.animate({cx: this.cx, "stroke-width": this.cx / 100, fill: this.cx - 100 ? "hsb(.2, .75, .75)" : "#000", "fill-opacity": +!!(this.cx - 100)}, 1000, "<");
  this.cx = this.cx == 300 ? 100 : 300;
});

取自于前面的例子

我不知道这个代码是否可以在版本2上工作,但是