Here is the problem :
i have a function, which should return nothing... it is called :
function zoom(event){
alert("wheel delta : "+event.wheelDelta);
return false;
}
on click on my element, i try to add an event listener on mousewheel this way :
element.addEventListener("mousewheel",zoom,false);
element is a svg tag. but, function zoom is never called, i only get this message back :
TypeError: Argument 2 of EventTarget.addEventListener is not an object.
what am I doing wrong?
Thanks for help :)
EDIT : here is the whole code :
function ZoomMain(){
var zoom = 0;
var main;
var clicks = 0;
this.click = function(event,svg){
if(svg){
switch(clicks%2){
case 0 :
main = svg;
main.addEventListener("mousewheel",zoom,false);
clicks++;
break;
case 1 :
main.removeEventListener("mousewheel",zoom,false);
clicks++;
break;
}
}else{
alert("ERROR");
}
};
function zoom(event){
alert("wheel delta : "+event.wheelDelta);
return false;
}
}
try
if
zoom
is not afunction
probably that's a scope issue. Add all relevant code for more help.PS: This is not a solution to the problem, but a solution to debug! If you are ok with developer tools, dubyg using that to see if
zoom
has a valid value.Paste the click event handler and how you are binding
mousewheel
event handler inside click event handler. Also show wherezoom
is defined with relative to these.http://jsfiddle.net/vucfrfke/3/
stupid issue, you redeclared
zoom