How to use eve() in Raphael?

旧巷老猫 提交于 2019-12-03 07:49:03

Simple example of the event functionality in Raphaël:

We define the function that will fire the event

function bar()
{
  var a, b;
  a = 1;
  b = 2;
  eve("run-foo", "self", a, b);
}

The event listener function

function foo(arg1, arg2, arg3)
{
  // if the event is fired from bar() :
  // this == "self"
  // arg1 == a == 1
  // arg2 == b == 2
  // arg3 == undefined/null
}
eve.on("run-foo", foo);

http://jsperf.com/eve-js-versus-events

Use Event.js. I think it is better. Not just faster. But understand the key conceptual difference. eve.js works without a DOM. Event.js is basicaly DOM events library. Although not 100%.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!