[mapguide-users] RE: OnMouseWheel Zoom in and Zoom out

kmtnck alessandro.modica at gmail.com
Wed Jul 14 06:27:10 EDT 2010


the bug is very insidios.

on line 3467 of function HandleMouseWheelEvent(delta, event) side on
ajaxmappane.templ in ../www/viewerfiles/ there are this code:

      wheelZoomCursor = new Point(msie ? event.clientX - mapPosX :
event.screenX - mapPosX,
            msie ? event.clientY : event.screenY);

Searching on google I find this link http://unixpapa.com/js/mouse.html that
explain this consideration:

In most browsers these coordinates are returned in event.pageX and
event.pageY. But IE does not implement these. For IE, you need to compute
them by adding the current scrolling offset to the the window coordinates.
Unfortunately, the scrolling offset is stored in different places in
different versions of IE, so this gets a bit complex:

   if (event.pageX == null)
      // IE case
      var d= (document.documentElement && 
              document.documentElement.scrollLeft != null) ?
             document.documentElement : document.body;
      docX= event.clientX + d.scrollLeft;
      docY= event.clientY + d.scrollTop;
      // all other browsers
      docX= event.pageX;
      docY= event.pageY;

If we can understand the code on ajaxmappane.templ we can observ that for
other browser (msie = false) the coordinates is getting from variable
screenX and screenY and this is wrong.

I fixed it with code:

      wheelZoomCursor = new Point(msie ? event.clientX - mapPosX :
event.pageX- mapPosX,
            msie ? event.clientY : event.pageY);

I attempt to override this handler in another js as workaround, but I
realize that the input args "event" is undefined! why?

There are other similar setting coordinates with screenX and screenY in
another .templ script of mapguide? I don't must upgrade mapguide 2.0 on 2.1
or 2.2 to fix the problem. I want to realize if exist an elegant workaround
to fix all bugs about it!!

screenX and screeY I can consider is coordinates of monitor visual and not
on particular range visual of frame. isn't ?

I try to open a ticket on trac mapguide, but I have got an denied permission
to access and I have difficult to register in! I trying soon for opening
this important ticket!


View this message in context: http://osgeo-org.1803224.n2.nabble.com/OnMouseWheel-Zoom-in-and-Zoom-out-tp4889474p5291900.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

More information about the mapguide-users mailing list