modestmaps / modestmaps-js

Modest Maps javascript port
http://modestmaps.com
395 stars 73 forks source link

Enabling/disabling, adding and removing event handlers #68

Closed cmtt closed 11 years ago

cmtt commented 11 years ago

A multiplication seems to be a tiny bit faster than a division in a few Gecko browsers, so I changed every "/ 2" to "* 0.5", have a look at: http://jsperf.com/multiply-vs-division

Despite that, this pull request allows event handlers to be de-/attached, removed and added back. In case of MouseWheelHandler, I have re-introduced a bind method (as a polyfill from MDN for old and beloved browsers) due to the _zoomDiv variable. Also, it was necessary to expose MouseHandler's handlers again.

Event handlers must have an id string, otherwise, the following new methods cannot determine what you'd refer to.

map.getHandler({String} id); map.disableHandler({String} id); map.enableHandler({String} id); map.removeHandler({String} id); map.addHandler({Function} handler);

tmcw commented 11 years ago

Cool with the direction of this pull request but there are a few issues:

cmtt commented 11 years ago

Thanks for the heads up, the pull request was changed accordingly