Skip to content

Commit

Permalink
Use MagnifyingGlassZoomButtonGroup, see phetsims/scenery-phet#652
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Feb 18, 2021
1 parent 6e47813 commit ab29543
Showing 1 changed file with 10 additions and 28 deletions.
38 changes: 10 additions & 28 deletions js/common/view/IntensityGraphPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import NumberProperty from '../../../../axon/js/NumberProperty.js';
import RangeWithValue from '../../../../dot/js/RangeWithValue.js';
import Utils from '../../../../dot/js/Utils.js';
import Shape from '../../../../kite/js/Shape.js';
import merge from '../../../../phet-core/js/merge.js';
import ZoomButton from '../../../../scenery-phet/js/buttons/ZoomButton.js';
import MagnifyingGlassZoomButtonGroup from '../../../../scenery-phet/js/MagnifyingGlassZoomButtonGroup.js';
import Line from '../../../../scenery/js/nodes/Line.js';
import Node from '../../../../scenery/js/nodes/Node.js';
import Path from '../../../../scenery/js/nodes/Path.js';
Expand Down Expand Up @@ -104,36 +103,19 @@ class IntensityGraphPanel extends WaveInterferencePanel {
// Reset zoom level when sim is reset
resetEmitter.addListener( () => zoomLevelProperty.reset() );

const zoomButtonOptions = {
magnifyingGlassOptions: {
glassRadius: 6
const zoomButtonGroup = new MagnifyingGlassZoomButtonGroup( zoomLevelProperty, {
spacing: 35,
top: titleNode.bottom + 13,
buttonOptions: {
baseColor: ColorConstants.LIGHT_BLUE
},
baseColor: ColorConstants.LIGHT_BLUE,
top: titleNode.bottom + 13
};

// Zoom out button on the left
const zoomOutButton = new ZoomButton( merge( {
in: false,
left: chartRectangle.left,
listener: () => zoomLevelProperty.value--
}, zoomButtonOptions ) );

// Zoom in button on the right
const zoomInButton = new ZoomButton( merge( {
in: true,
right: chartRectangle.right,
listener: () => zoomLevelProperty.value++
}, zoomButtonOptions ) );

// Disable zoom buttons at the extrema
zoomLevelProperty.link( zoomLevel => {
zoomOutButton.enabled = zoomLevel > zoomRange.min;
zoomInButton.enabled = zoomLevel < zoomRange.max;
magnifyingGlassNodeOptions: {
glassRadius: 6
}
} );

const chartNode = new Node( {
children: [ chartRectangle, curve, titleNode, zoomOutButton, zoomInButton ]
children: [ chartRectangle, curve, titleNode, zoomButtonGroup ]
} );

super( chartNode, options );
Expand Down

0 comments on commit ab29543

Please sign in to comment.