最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Someone can provide some code example for Raphael JS events? - Stack Overflow

programmeradmin2浏览0评论

I don't know how to use Raphael JS events.

I need some example. I see the documentation and a function must be passed, but is not working.

Someone can provide some example of how to get the mouse position of a click in the canvas?

EDIT: I see in documentation events for Element. This will work for Paper? How I create a mousedown() event for Paper?

I don't know how to use Raphael JS events.

I need some example. I see the documentation and a function must be passed, but is not working.

Someone can provide some example of how to get the mouse position of a click in the canvas?

EDIT: I see in documentation events for Element. This will work for Paper? How I create a mousedown() event for Paper?

Share Improve this question edited Oct 6, 2011 at 4:43 Renato Dinhani asked Oct 5, 2011 at 19:49 Renato DinhaniRenato Dinhani 36.8k58 gold badges140 silver badges202 bronze badges 3
  • Are you using Raphael 2? – CamelCamelCamel Commented Oct 5, 2011 at 19:51
  • @Radagaisus Raphael JS, a javascript library for drawnig, graphics, etc. – Renato Dinhani Commented Oct 5, 2011 at 19:55
  • I know :) a few days ago version 2 of the library was published. Thus my question. – CamelCamelCamel Commented Oct 5, 2011 at 20:03
Add a ment  | 

2 Answers 2

Reset to default 4
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);
});

check out the source code in the Raphael examples.

Here's another example with a click event:

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;
});

which is taken from the easing example.

I don't know if the code will work on version 2, though

发布评论

评论列表(0)

  1. 暂无评论