Thanks, I have this to share about the subject, based on what I got 
here on THIS thread.

//the sandbox is a javascript object that draws all of the SVG objects
var mObjSandBox = new SandBox(<parameters>);
..
function SandBox(< parameters>)
.
.
my custom stuff here
.
this.down = false
        this.lastX; 
        this.lastY;
        this.tx = 0;
        this.ty = 0;

        this.svgDoc.documentElement.addEventListener( "mousedown", 
Down, false );
        this.svgDoc.documentElement.addEventListener( "mouseup", Up, 
false );
        this.svgDoc.documentElement.addEventListener( "mousemove", 
Move, false );
}

function Down(evt)
{
  mObjSandBox.lastX = evt.clientX;
  mObjSandBox.lastY = evt.clientY;
  mObjSandBox.down = true;
}

function Up(evt)
{
   mObjSandBox.down = false;
}

function Move(evt)
{
        if( ! mObjSandBox.down )
        {
                return;
        }
        var x = evt.clientX;
        var y = evt.clientY;
        var dx = x - mObjSandBox.lastX;
        var dy = y - mObjSandBox.lastY;
        mObjSandBox.lastX = x;
        mObjSandBox.lastY = y;
        
        if( evt.shiftKey )
        {
                mObjSandBox.svgDoc.documentElement.currentTranslate.x 
+= dx;
                mObjSandBox.svgDoc.documentElement.currentTranslate.y 
+= dy;
        }
        else
        {
                mObjSandBox.tx += dx;
                mObjSandBox.ty += dy;
                mObjSandBox.svgDoc.rootElement.setAttribute
("transform", "translate("+mObjSandBox.tx+","+mObjSandBox.ty+")" )
        }
}

function ZoomUp()
{
        var objList = document.all("ddlZoom");
        if (objList.options.length-1 > objList.selectedIndex)
        {
                objList.selectedIndex++;
                Zoom();
        }
}

function ZoomDown()
{
        var objList = document.all("ddlZoom");
        if (objList.selectedIndex > 0)
        {
                objList.selectedIndex--;
                Zoom();
        }
}

function ddlZoomPopulate() 
{
        var objList = document.all("ddlZoom").options;
        for (var i=2; i<21; i++)
        {
                var iIndex = objList.length++
                with(objList[iIndex]) { value=(i/10); text=(i*10)
+"%"; };
        }
        
        objList.disabled = false;
}

//on the page somewhere i have this.
<select id="ddlZoom"  onchange="Zoom();" disabled></select>

Now I would love to have some way that all of this can be integrated 
into my base SandBox. I am somewhat new to the strange way that 
object inherit from each other in javascript. Sometimes I really like 
it, and other times it confuses the heck out of me.

I don't like having to hardcode the Move functions to the mObjSandBox
so that they can use its properties. It would be nice to share these 
functions with any other SVG object that I have on the page. I would 
love to find a way around the inability of events to return a parent 
object (at least with IE). The "this" object, even if the move 
objects are from the parent SandBox, refers uselessly to the main 
document window instead of my desired objects.

BTW, If this code is to run on Mozilla, "document.all" must be 
replaced with a function that returns the right object in either 
browser. But I am working on an IE-only intranet so that simplifies 
things.





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/TtwFAA/1U_rlB/TM
--------------------------------------------------------------------~-> 

-----
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/

<*> 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