From 61b98dd29ec4926db90d5c2478fe4f33702c41c6 Mon Sep 17 00:00:00 2001 From: Marla Schulz Date: Tue, 23 Aug 2022 14:50:43 -0400 Subject: [PATCH] Update text layout --- js/QuestionBar.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/QuestionBar.ts b/js/QuestionBar.ts index 6cce7c39..0a7cf9cb 100644 --- a/js/QuestionBar.ts +++ b/js/QuestionBar.ts @@ -16,9 +16,11 @@ import Bounds2 from '../../dot/js/Bounds2.js'; import PhetFont from '../../scenery-phet/js/PhetFont.js'; import Tandem from '../../tandem/js/Tandem.js'; import TProperty from '../../axon/js/TProperty.js'; +import TReadOnlyProperty from '../../axon/js/TReadOnlyProperty.js'; +import Multilink from '../../axon/js/Multilink.js'; type SelfOptions = { - labelText: string; + labelText: string | TReadOnlyProperty; }; export type QuestionBarOptions = SelfOptions & StrictOmit; @@ -43,10 +45,11 @@ class QuestionBar extends StatusBar { maxWidth: layoutBounds.width - QUESTION_TEXT_MARGIN * 2, tandem: options.tandem.createTandem( 'labelText' ) } ); + this.addChild( labelText ); - this.positioningBoundsProperty.link( bounds2 => { - labelText.centerY = bounds2.centerY; + Multilink.multilink( [ labelText.localBoundsProperty, this.positioningBoundsProperty ], ( localBounds, positioningBounds ) => { + labelText.centerY = positioningBounds.centerY; labelText.left = QUESTION_TEXT_MARGIN; } ); }