Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 6969

Even after placing element outside the group element is moving with group

$
0
0

@Abhishek wrote:

If i am placing an element inside the group and later placing it outside that group, the group is still maintained in the model and on moving that group the element/Part is moving with it.
Also while resizing this group it is getting displaced from its original location.
Each time i try to resize while clicking on resizing adornment it is getting shifted a little downwards.

using following group template

    this.diagram.groupTemplate =
      $(go.Group, "Vertical",        
        { dragComputation: stayInFixedArea }, 
        $(go.Shape, "Rectangle",  // the rectangular shape around the members
          {
            name: "SHAPE",
            fill: groupFill,
            stroke: groupStroke,
            minSize: new go.Size(CellSize.width * 2, CellSize.height * 2)
          },
          new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify),
          new go.Binding("fill", "isHighlighted", function(h) { return h ? dropFill : groupFill; }).ofObject(),
          new go.Binding("stroke", "isHighlighted", function(h) { return h ? dropStroke : groupStroke; }).ofObject()), 
        {
          layerName: "BlockLayer",
          resizable: true, resizeObjectName: "SHAPE",
          // because the gridSnapCellSpot is Center, offset the Group's location
          locationSpot: new go.Spot(0, 0, CellSize.width / 2, CellSize.height / 2),
          zOrder:1
        },
        // always save/load the point that is the top-left corner of the node, not the location
        new go.Binding("position", "pos", go.Point.parse).makeTwoWay(go.Point.stringify),
        { // what to do when a drag-over or a drag-drop occurs on a Group
          mouseDragEnter: function(e, grp, prev) { highlightGroup(grp, true); },
          mouseDragLeave: function(e, grp, next) { highlightGroup(grp, false); },
          mouseDrop: function(e, grp) {
            var ok = grp.addMembers(grp.diagram.selection, true);
            if (!ok) grp.diagram.currentTool.doCancel();
          }
        },
        $(go.TextBlock, 
          {editable:true, textAlign: 'right', alignment: go.Spot.BottomRight, verticalAlignment: go.Spot.Bottom},  
          new go.Binding("text", "key").makeTwoWay())
      );

      // decide what kinds of Parts can be added to a Group
    this.diagram.commandHandler.memberValidation = function(grp, node) {
      if (grp instanceof go.Group && node instanceof go.Group) return false;  // cannot add Groups to Groups
      // but dropping a Group onto the background is always OK
      return true;
    };

After placing it outside, the model still has the group and on moving element keeps moving with group

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6969

Trending Articles