Hello

I have the following function triggered by mousewheel event handler for zooming.


function ZoombyWheel(SVG_Name, ZoomChangePercent, ZoomCenterX, ZoomCenterY) {
    if (window.addEventListener) {//Not IE
        document.getElementById(SVG_Name).viewBox.baseVal.x = 
document.getElementById(SVG_Name).viewBox.baseVal.x * (1 - ZoomChangePercent * 
ZoomCenterX);
        document.getElementById(SVG_Name).viewBox.baseVal.y = 
document.getElementById(SVG_Name).viewBox.baseVal.y * (1 - ZoomChangePercent * 
ZoomCenterY);
        document.getElementById(SVG_Name).viewBox.baseVal.width = 
document.getElementById(SVG_Name).viewBox.baseVal.width * (1 - 
ZoomChangePercent);
        document.getElementById(SVG_Name).viewBox.baseVal.height = 
document.getElementById(SVG_Name).viewBox.baseVal.height * (1 - 
ZoomChangePercent);
    }
    else {
        var S = getAttr(document.getElementById(SVG_Name), 'viewBox');

        var Arr = S.split(" ");

        Arr[0] = Arr[0] * (1 - ZoomChangePercent * ZoomCenterX);
        Arr[1] = Arr[1] * (1 - ZoomChangePercent * ZoomCenterX);
        Arr[2] = Arr[2] * (1 - ZoomChangePercent);
        Arr[3] = Arr[3] * (1 - ZoomChangePercent);

        S = Arr[0] + " " + Arr[1] + " " + Arr[2] + " " + Arr[3];
        
//document.getElementById(SVG_Name).attributes.removeNamedItem('viewBox')
        document.getElementById(SVG_Name).setAttributeNS(null,'viewBox', S);
        /*
        for (var i = 0; i < 
document.getElementById(SVG_Name).attributes.length; i++)
            if (document.getElementById(SVG_Name).attributes[i].nodeName === 
'viewBox')
                document.getElementById(SVG_Name).attributes[i].nodeValue = S;
        */
    } 
}

commented parts show lots of try and errors that I've done for solving my 
problem. First part that is for non IE browsers has worked well in chrome.

next part (else block)which is for IE is assumed to easily change viewbox, but 
in real world it sucks.

If I use setAttribute, attribute is set but no change in real graphics. The 
same result happens when I use attributes collection. setAttributeNS completely 
fails with error :Object doesn't support property or method 'setAttributeNS'.

Could you pleas help?




------------------------------------

-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to