How to use eve () in Raphael?

Can someone give me a simple example of Raphael eve() ?

I do not quite understand the parameters and how to trigger events. I searched around a bit, but it seems that not many people have used it.

+6
source share
2 answers

A simple example of event functionality in RaphaΓ«l :

Define the function that will trigger the event

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

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); 
+3
source

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

Use Event.js . I think this is better. Not only faster. But understand the key conceptual difference. eve.js works without the DOM. Event.js is the core DOM event library. Although not 100%.

+2
source

Source: https://habr.com/ru/post/907010/


All Articles