Commit ad288f4e authored by S Anand's avatar S Anand

ENH: add event listeners to G.zoom(). Fixes #28

parent 909f0db0
This diff is collapsed.
......@@ -31,6 +31,13 @@ G.zoom = function(options) {
}
return {
// self.on(event, handler) binds handler to event on both smoothzoom and abruptzoom
// e.g. self.on('zoomstart', handler)
'on': function(event, handler) {
smoothzoom.on(event, handler)
abruptzoom.on(event, handler)
},
'to': function (nodes) {
var bounds={},
i=0,
......@@ -46,7 +53,7 @@ G.zoom = function(options) {
box.x += +trans[1]
box.y += +trans[2]
}
/* jshint -W018 */ // ignore confusing use of ! message
/* jshint -W018 */ // ignore confusing use of ! message. ! is needed to handle invalid values
if (!(box.x >= bounds.x)) bounds.x = box.x
if (!(box.y >= bounds.y)) bounds.y = box.y
if (!(box.x + box.width <= bounds.x2)) bounds.x2 = box.x + box.width
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment