Duder-onomy / svgpan

Automatically exported from code.google.com/p/svgpan
0 stars 0 forks source link

mouse wheel zooming does not work in Opera 11, IE9 #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The image does not zoom in these browsers. It works fine in chrome and Firefox 5

Original issue reported on code.google.com by zdenek.k...@gmail.com on 22 Jun 2011 at 4:34

GoogleCodeExporter commented 9 years ago
If you use this this code:

if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
        window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel;

to setup mousewheel events instead of the one in SVGPAN.js then it works also 
in Opera and IE9.

Original comment by nikba...@gmail.com on 2 Dec 2011 at 6:42

GoogleCodeExporter commented 9 years ago
The following seemed to work for me (version 1.2.2):

    //if(navigator.userAgent.toLowerCase().indexOf('webkit') >= 0)
            window.addEventListener('mousewheel', handleMouseWheel, false); // Chrome/Safari
    //else
            window.addEventListener('DOMMouseScroll', handleMouseWheel, false); // Others

Original comment by lukas.to...@htwchur.ch on 8 Feb 2012 at 11:10

GoogleCodeExporter commented 9 years ago
I modified it as follows to get it to work in Opera, Chrome, Safari, Firefox, 
and IE9:

    if (navigator.userAgent.match(/like Mac OS X/i)) {
        window.addEventListener('gesturechange',handleMouseWheel,false); // iOS gestures (UNTESTED)
    } else if (navigator.userAgent.toLowerCase().indexOf('firefox') >= 0) {
        window.addEventListener('DOMMouseScroll', handleMouseWheel, false); // Firefox
    } else {
        window.addEventListener('mousewheel', handleMouseWheel, false); // Chrome/Safari/Opera/Explorer9
    }

I haven't yet tested the iOS gesture code.

Original comment by r...@cornell.edu on 13 Jul 2012 at 3:05

GoogleCodeExporter commented 9 years ago
@ #3

Had to change it from window.addEventListener… to root.addEventListener… to 
make it work. Thanks! 

Original comment by gilmar.a...@gmail.com on 21 Oct 2013 at 12:12

GoogleCodeExporter commented 9 years ago
I tried all the above but could not get it to work properly in IE11...

Original comment by wole...@gmail.com on 12 Jan 2015 at 2:27

GoogleCodeExporter commented 9 years ago
I traced the source of the problem to getEventPoint...

I amended the code as below and it worked!

/**
 * Instance an SVGPoint object with given event coordinates.
 */
function getEventPoint(evt) {
    if(evt==null){return;}
    var p;
    try
    {
        p = root.createSVGPoint();
    }
    catch(e)
    {
    }

    if(p==null)
    {
        var svgDoc = evt.target.ownerDocument;
        var g = getRoot(svgDoc);
        p = g.nearestViewportElement.createSVGPoint();
    }

    p.x = evt.clientX;
    p.y = evt.clientY;

    return p;
}

Original comment by wole...@gmail.com on 12 Jan 2015 at 3:16