Skip to content

Commit

Permalink
#275 add doc to LayoutBox while investigating potential mutability of…
Browse files Browse the repository at this point in the history
… spacing
  • Loading branch information
pixelzoom committed Jul 13, 2015
1 parent 3f973f5 commit 3555377
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js/nodes/LayoutBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ define( function( require ) {
this.options.spacing = function() { return spacingConstant; };
}

this.updatingLayout = false; // @private flag used to short-circuit updateLayout and prevent stackoverflow

// Apply the supplied options, including children.
// The layout calls are triggered if (a) options.resize is set to true or (b) during initialization
// When true, the this.inited flag signifies that the initial layout is being done.
Expand Down Expand Up @@ -99,7 +101,7 @@ define( function( require ) {
else if ( this.options.align === 'right' ) {
child.right = maxX;
}
else {//default to center
else { // 'center'
child.centerX = centerX;
}

Expand Down Expand Up @@ -129,7 +131,7 @@ define( function( require ) {
child.centerY = centerY;
}

//Move to the next vertical position.
//Move to the next horizontal position.
x += child.width + this.options.spacing( child, this._children[ i + 1 ] );
}
}
Expand All @@ -138,8 +140,8 @@ define( function( require ) {
// Update the layout of this VBox. Called automatically during initialization, when children change (if resize is true)
// or when client wants to call this public method for any reason.
updateLayout: function() {
//Bounds of children are changed in updateLayout, we don't want to stackoverflow, so bail if already updating layout
if ( !this.updatingLayout ) {
//Bounds of children are changed in updateLayout, we don't want to stackoverflow so bail if already updating layout
this.updatingLayout = true;
this.layout();
this.updatingLayout = false;
Expand Down

0 comments on commit 3555377

Please sign in to comment.