okay I've been working on the "overlap" collision detection, using a simple 
bounding box algorithm - it seems to work fine.
Where do we go from here, any suggested changes? I think we should give the 
user the opportunity of choosing the drop event they are looking for - 
possibly as described below  - how would I implement this, different 
include files?:
DrapDrop
DragOverLap
DragEnclose
What about optimisation? Is there or can we build global arrays for each 
listener type, holding all the objects registered for that listener?

Regards

Mark
PS which list should I be sending this to - is it a help question, or a dev 
question? Last time advice was offered on help, but I think its more a dev 
question so am sending it to both for now.
------------------------code---------------------------------------------------------------------------
DynObject.prototype.DragDrop=function(s,e){
        if (!this.children.length>0) return false;
        var ch,chX1,chY1,chX2,chY2,sX1,sY1,sX2, sY2;;
        sX1 = s.getPageX();
        sY1 = s.getPageY();
        sX2 = sX1 + s.getWidth();
        sY2 = sY1 + s.getHeight();
        
        for (var i in this.children) {
                ch=this.children[i];
                if(ch!=s) {
            chX1 = ch.getPageX();
            chY1 = ch.getPageY();
            chX2 = chX1 + ch.getWidth();
            chY2 = chY1 + ch.getHeight();
            if ((chY1<=sY1&&chY2>=sY1||  //top overlap
                 chY1<=sY2&&chY2>=sY2||  //bottom overlap
                 chY1>=sY1&&chY2<=sY2)&& //horizontallly enclosed
           (chX1<=sX1&&chX2>=sX1||  //left overlap
            chX1<=sX2&&chX2>=sX2||  //right overlap
            chX1>=sX1&&chX2<=sX2)) {
                          //if (ch.DragDrop(s,e)) return true;
                                ch.invokeEvent("drop");
                                return true;
                        }               
                }
        }
        return false;
};
--------------original 
message------------------------------------------------------------------------------------
I posted this on the help mailing list, but thought its probably more a 
development issue:

I have drag drop working without a problem, but I notice it only fires the 
listener if the mouse is released over the target. I'm about to try and 
write something that will fire if there is any over lap at all between 
source and target layers - has any work been done on this, does anyone have 
any pointers?

My reasoning for doing this is that I'm trying to build a system where a 
user can position layers, but layers are not allowed to overlap - so if 
someone moves one layer over the other it should snap to the correct 
position to avoid overlapping.
-----------------------------
on further thought I think there are several events you might want to 
listen for:
drag and drop with mouse released within target area
drag and drop with source and target overlapping
drag and drop with source entirely enclosed within target
drag and drop with target totally enclosed within source

Anyone working on any of those? I'm going to start work on the one of 
interesting to me, the overlapping one, but it would be nice to build a 
framework for all of these, and any others I have forgotten. Other reasons 
why the overlapping one might be good as it allows animated layers to 
interact, you could do a demo of  balls bouncing into each other etc.


_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to