Skip to content

Commit

Permalink
Reentrancy improvements for maxWidth/maxHeight, see phetsims/joist#725
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Jul 10, 2021
1 parent 64ade06 commit f0adace
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions js/nodes/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,11 @@ class Node extends PhetioObject {

sceneryLog && sceneryLog.bounds && sceneryLog.bounds( `localBounds: ${ourLocalBounds}` );

// adjust our transform to match maximum bounds if necessary on a local bounds change

This comment has been minimized.

Copy link
@zepumph

zepumph Jul 12, 2021

Member

@jonathanolson, can you document why this needed to go before the localBounds notification stuff?

This comment has been minimized.

Copy link
@jonathanolson

jonathanolson Jul 12, 2021

Author Contributor

Done in aa0952d

if ( this._maxWidth !== null || this._maxHeight !== null ) {
this.updateMaxDimension( ourLocalBounds );
}

if ( !ourLocalBounds.equals( oldLocalBounds ) ) {
// sanity check, see https://github.com/phetsims/scenery/issues/1071, we're running this before the localBounds
// listeners are notified, to support limited re-entrance.
Expand All @@ -1281,11 +1286,6 @@ class Node extends PhetioObject {
this.localBoundsProperty.notifyListeners( oldLocalBounds );
}
}

// adjust our transform to match maximum bounds if necessary on a local bounds change
if ( this._maxWidth !== null || this._maxHeight !== null ) {
this.updateMaxDimension( ourLocalBounds );
}
}

// TODO: layout here?
Expand Down Expand Up @@ -2768,9 +2768,10 @@ class Node extends PhetioObject {

const scaleAdjustment = idealScale / currentScale;
if ( scaleAdjustment !== 1 ) {
this.scale( scaleAdjustment );

// Set this first, for supporting re-entrancy if our content changes based on the scale
this._appliedScaleFactor = idealScale;

this.scale( scaleAdjustment );
}
}

Expand Down

0 comments on commit f0adace

Please sign in to comment.