Hello Everyone,

Modify dragevents.js starting at line 107 to reflect
the following:

// Respect boundary, if any
if (lyr._dragBoundary) {
        var dB = lyr._dragBoundary;
        var t = dB.top;
        var r = dB.right;
        var b = dB.bottom;
        var l = dB.left;
        // prevent choppy dragging if child is greater than
parent
        var pw = (lyr.parent.w>lyr.w)?
lyr.parent.w-lyr.w:lyr.x;
        var ph = (lyr.parent.h>lyr.h)?
lyr.parent.h-lyr.h:lyr.y;
        if (x<l) x = l;
        else if (x>pw-r) x = pw-r;
        if (y<t) y = t;
        else if (y>ph-b) y = ph-b;
}

Please see the attacted file for testing the new code.
If it now works as if should then please let me know.


PS. Please note that DynLayer.setDragMode will be
changed to DynLayer.setDragEnabled(d,useIcon)

--
Raymond Irving

--- Brian Hayes <[EMAIL PROTECTED]> wrote:
> Dear developer's,
>  
>             I wanted to share a code change that I
> made today with version
> 3, as it relates to the setDragBoundary function is
> DragEvents. I noticed
> that when you enable boundaries and you have this
> within a containing object
> that was smaller than the one with limits you would
> get very choppy
> behavior. I worked around this by using the
> eventlistener "ondragmove" and
> "ondragstop", by setting my location based on the
> area of my container..
> Then it hit me, while working on the
> dynapi.function.getimage and some guys
> from work whom specialize in oop style programing..
> add the code to the core
> dragevent.js file (line 113), and not longer worry
> about it.. So here it is,
> and please let me know what  could do better (if
> any, as math is hard for me
> to visualize)..
>  
> Origianal Code..
>                                                 //if
> (x<l) x = l;
>                                                
> //else if
> (x>lyr.parent.w-lyr.w-r) x = lyr.parent.w-lyr.w-r;
>                                                 //if
> (y<t) y = t;
>                                                
> //else if
> (y>lyr.parent.h-lyr.h-b) y = lyr.parent.h-lyr.h-b;
>  
> New Code..
>                                                
> if(lyr.parent.w>lyr.w){ //
> We are in a container larger than we are, so use the
> orignal code..
>                                                     
>        if (x<l) x = l;
>                                                     
>        else if
> (x>lyr.parent.w-lyr.w-r) x = lyr.parent.w-lyr.w-r;
>                                                     
>        if (y<t) y = t;
>                                                     
>        else if
> (y>lyr.parent.h-lyr.h-b) y = lyr.parent.h-lyr.h-b;
> 
>                                                 }
> else
> if(lyr.parent.w<lyr.w){ //opps we are larger than
> our container, so make us
> smother to our areas..
>                                                     
>        if ( (x*-1) < l)
> x = l; 
>                                                     
>        else if (
> ((x*-1) +lyr.parent.w-r) >= lyr.w) x =
> lyr.parent.w-lyr.w-r;
>                                                     
>        if ( (y*-1) < t)
> y = t;
>                                                     
>        else if (
> ((y*-1) +lyr.parent.h-b) >= lyr.h) y =
> lyr.parent.w-lyr.h-b;
>                                                 }
>  
> The above allows the borders to flow very smooth..
> Please let me know what
> you think, and if you have a cleaner way of writing
> the above.. 
>  
> Example:
>  
> var container = new
> DynLayer(null,0,0,200,200,"e0e0e0"); 
> var insideObj = new DynLayer("Inside",0,0,400,400,
> "blue"); larger than our
> container...
> container.addChild(insideObj);
> dynapi.document.addChild(container);
> dynapi.document.insertAllChildren();
>  
> Thanks... Brian Hayes.
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

Attachment: drag_large_layer.zip
Description: drag_large_layer.zip

Reply via email to