Reputation: 19856
Using d3.js, I have a strange issue. The following code works fine:
var zoomHandler = d3.behavior.zoom()
.scaleExtent([min, max])
.on("zoom", function() {
// do something;
}).on("zoomend", function() {
// do something;
});
But, I also want my zoomHandler to deactivate another event, so I tried to extend the code like this:
var zoomHandler = d3.behavior.zoom()
.scaleExtent([min, max])
.on("zoom", function() {
// do something;
}).on("zoomend", function() {
// do something;
}).on("otherEvent", null);
But now, at runtime, I get an exception
Uncaught TypeError: Cannot read property 'on' of undefined
Why can I only add two listeners but not three?
Upvotes: 1
Views: 73
Reputation: 14063
Your problem isn't with the number of events, it's the event type "otherEvent" (or whatever you're using in your code). The Zoom behavior only supports zoom events:
The following types are supported:
- zoomstart - at the start of a zoom gesture (e.g., touchstart).
- zoom - when the view changes (e.g., touchmove).
- zoomend - at the end of the current zoom gesture (e.g., touchend).
Upvotes: 2