javascript - add mousewheel eventlistener error -
javascript - add mousewheel eventlistener error -
here problem :
i have function, should homecoming nothing... called :
function zoom(event){ alert("wheel delta : "+event.wheeldelta); homecoming false; }
on click on element, seek add together event listener on mousewheel way :
element.addeventlistener("mousewheel",zoom,false);
element svg tag. but, function zoom never called, message :
typeerror: argument 2 of eventtarget.addeventlistener not object.
what doing wrong?
thanks help :)
edit : here 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); homecoming false; } }
try
if(typeof zoom === "function"){ element.addeventlistener("mousewheel",zoom,false); } else{ alert(zoom); }
if zoom
not function
that's scope issue. add together relevant code more help.
ps: not solution problem, solution debug! if ok developer tools, dubyg using see if zoom
has valid value.
on click on element, seek add together event listener on mousewheel
paste click event handler , how binding mousewheel
event handler within click event handler. show zoom
defined relative these.
http://jsfiddle.net/vucfrfke/3/
stupid issue, redeclared zoom
javascript function events addeventlistener mousewheel
Comments
Post a Comment