ericabouaf / wireit

A javascript wiring library to create web wirable interfaces for dataflow applications, visual programming languages or graphical modeling.
http://neyric.github.io/wireit/docs/
Other
520 stars 90 forks source link

Resize issue with containers #52

Closed sprat closed 12 years ago

sprat commented 13 years ago

I found out that, when you have a layer with some containers and you resize the browser window, the X,Y constraints are not set correctly, so you can't drag your container to the (new) top left corner of the layer. I'm investigating the issue, I think the problem is related to the Container.makeDraggable function.

sprat commented 13 years ago

Here is how I solved the problem:

setXYContraints: function() {
    if(this.layer) {
        var layerPos = Dom.getXY(this.layer.el);
        var pos = Dom.getXY(this.el);
        // remove the layer position to the container position            
        this.dd.setXConstraint(pos[0] - layerPos[0]);
        this.dd.setYConstraint(pos[1] - layerPos[1]);
    }
    // FIXME: what if there's no layer?
},

/**
 * Use the DD utility to make container draggable while redrawing the connected wires
 */
makeDraggable: function() {
    // Use the drag'n drop utility to make the container draggable
   this.dd = new WireIt.util.DD(this.terminals,this.el);

   // set the XY constraints that limit the drag area      
   YAHOO.util.Event.on(window, 'resize', this.setXYContraints, this, true);   
   this.setXYContraints();
   ...