Skip to content

Commit

Permalink
use swapVisibility to manage focus, see #104
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Oct 19, 2017
1 parent 400d984 commit a3060ce
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions js/lab/view/LabPlayPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ define( function( require ) {
self.setPlayButtonVisible(); // show the play button
} );

// create a separate node to hold the play and pause button
var playPlayPauseButton = new Node();
// @private - create a separate node to hold the play and pause button
this.playPlayPauseButton = new Node();

// add the play and pause button
playPlayPauseButton.addChild( this.playButton );
playPlayPauseButton.addChild( this.pauseButton );
this.playPlayPauseButton.addChild( this.playButton );
this.playPlayPauseButton.addChild( this.pauseButton );

// create the content of the panel, with the play pause button and the radio buttons
var startVBox = new HBox( {
spacing: 20,
children: [
playPlayPauseButton,
this.playPlayPauseButton,
ballModeRadioButtons
]
} );
Expand All @@ -155,8 +155,10 @@ define( function( require ) {
*/
togglePlayPauseButtonVisibility: function() {
assert && assert( this.playButton.visible !== this.pauseButton.visible, 'the visibility of the play and pause buttons should alternate' );
this.playButton.visible = !this.playButton.visible;
this.pauseButton.visible = !this.pauseButton.visible;

var visibleButton = this.playButton.visible ? this.playButton : this.pauseButton;
var invisibleButton = this.playButton.visible ? this.pauseButton : this.playButton;
this.playPlayPauseButton.swapVisibility( visibleButton, invisibleButton );
},

/**
Expand Down

0 comments on commit a3060ce

Please sign in to comment.