I think I may have discovered a bug with the minSize and textBlocks. We are making a “notes” node type in which people can type in a note and move it and resize it anywhere on their map.
When I set the minSize on the Node element, I am not able to set the textBlock to a smaller width than the Node’s set width. The height setting doesn’t seem to have an issue, only width. Is this a bug in the framework?
Here’s a gif of the issue:
Here’s the code for the Node type. Changing the Node’s minSize width to “NaN” fixes the issue.
noteNodeTemplate = _self._go(go.Node, "Spot",{
isLayoutPositioned: false,
layerName: "Notes",
movable: false,
selectionAdorned: false,
location: new go.Point( -50, -50 ),
minSize: new go.Size( 270, 200 ),
resizable: true,
resizeAdornmentTemplate:
_self._go(go.Adornment, "Spot",
_self._go( go.Placeholder ),
_self._go( go.Panel, {
alignment: new go.Spot( 1, 1, -15, -15 ),
cursor: "pointer",
name: "resizeHandle"
},
_self._go(go.Shape, {
alignment: new go.Spot( 0.5, 0.5 ),
height: 30, width: 30,
fill: "transparent",
strokeWidth: 0
}
),
_self._go( go.Shape, {
strokeWidth: 0, fill: "#8a8a8a",
alignment: new go.Spot( 0.5, 0.5 ),
geometryString: go.Geometry.fillPath( "M14.47 13.06 10.94 9.53 9.53 8.12 11.64 6 6.01 6.01 6 11.64 8.12 9.53 9.53 10.94 13.06 14.47 14.47 15.88 12.36 17.99 17.99 17.99 18 12.36 15.88 14.47 14.47 13.06" )
})
)
)
},
_self._go(go.Shape, {
alignment: new go.Spot( 0.5, 0.5 ),
name: "BODY",
height: 100, width: 160,
fill: "#ffffff",
strokeWidth: 2,
strokeDashArray: [6, 4],
stroke: "#8a8a8a"
},
new go.Binding( "height", "height", function( val, obj ) {
return ( +val - 3 );
}),
new go.Binding( "width", "width", function( val, obj ) {
return ( +val - 3 );
})
),
_self._go(go.TextBlock, {
alignment: new go.Spot(0, 0, 20, 10),
name: "textBlock",
stroke: '#8a8a8a',
cursor: 'text',
background: 'blue',
text: "test this text",
font: '16px sans-serif',
editable: true,
textEdited: function( obj, prevText, newText ) {
if ( newText == "" ) {
obj.text = $l( 'Body of the note goes here' );
}
}},
new go.Binding( "height", "height", function( val, obj ) {
var currAlignment = obj.alignment;
obj.alignment = new go.Spot( currAlignment.x, currAlignment.y, currAlignment.offsetX, ( val / 2 ) );
return ( +val - 60 ); // subtract to provide padding
}),
new go.Binding( "width", "width", function( val, obj ) {
var currAlignment = obj.alignment;
obj.alignment = new go.Spot( currAlignment.x, currAlignment.y, ( val / 2 ), currAlignment.offsetY );
return ( +val - 20 ); // subtract to provide padding
})
),
new go.Binding( "height", "height").makeTwoWay(),
new go.Binding( "width", "width").makeTwoWay(),
new go.Binding("location", "_location", go.Point.parse ).makeTwoWay( go.Point.stringify )
);