Skip to content

Commit

Permalink
adjust tandem hierarchy and naming for container and its children, #30
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed May 1, 2024
1 parent 194cf14 commit b402e80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions js/common/view/IdealGasLawContainerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class IdealGasLawContainerNode extends Node {
baseWidth: modelViewTransform.modelToViewDeltaX( container.lidWidthProperty.value ),
baseHeight: modelViewTransform.modelToViewDeltaX( container.lidThickness ),
gripColor: options.lidGripColor,
tandem: options.tandem.createTandem( 'lidNode' )
lidHandleNodeTandem: options.tandem.createTandem( 'lidHandleNode' )
} );
const lidHandleNode = lidNode.handleNode;

Expand Down Expand Up @@ -167,10 +167,10 @@ export default class IdealGasLawContainerNode extends Node {

// Dragging the resize handle horizontally changes the container's width
const resizeHandleDragListener = new ResizeHandleDragListener( container, modelViewTransform, this,
resizeHandleNode.tandem.createTandem( 'resizeHandleDragListener' ) );
resizeHandleNode.tandem.createTandem( 'dragListener' ) );
resizeHandleNode.addInputListener( resizeHandleDragListener );
const resizeHandleKeyboardDragListener = new ResizeHandleKeyboardDragListener( container, modelViewTransform,
resizeHandleNode.tandem.createTandem( 'resizeHandleKeyboardDragListener' ) );
resizeHandleNode.tandem.createTandem( 'keyboardDragListener' ) );
resizeHandleNode.addInputListener( resizeHandleKeyboardDragListener );

// While interacting with the resize handle...
Expand All @@ -197,10 +197,10 @@ export default class IdealGasLawContainerNode extends Node {

// Dragging the lid's handle horizontally changes the size of the opening in the top of the container.
const lidHandleDragListener = new LidHandleDragListener( container, modelViewTransform, this,
lidHandleNode.tandem.createTandem( 'lidHandleDragListener' ) );
lidHandleNode.tandem.createTandem( 'dragListener' ) );
lidHandleNode.addInputListener( lidHandleDragListener );
const lidHandleKeyboardDragListener = new LidHandleKeyboardDragListener( container, modelViewTransform,
lidHandleNode.tandem.createTandem( 'lidHandleKeyboardDragListener' ) );
lidHandleNode.tandem.createTandem( 'keyboardDragListener' ) );
lidHandleNode.addInputListener( lidHandleKeyboardDragListener );

// This implementation assumes that the lid is not interactive while the container is being resized. This is
Expand Down
6 changes: 4 additions & 2 deletions js/common/view/LidNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { InteractiveHighlighting, Node, NodeOptions, NodeTranslationOptions, Rec
import gasProperties from '../../gasProperties.js';
import GasPropertiesColors from '../GasPropertiesColors.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import Tandem from '../../../../tandem/js/Tandem.js';

// constants
const HANDLE_ATTACHMENT_LINE_WIDTH = 1;
Expand All @@ -22,9 +23,10 @@ type SelfOptions = {
baseWidth: number;
baseHeight: number;
gripColor?: TColor;
lidHandleNodeTandem: Tandem;
};

type LidNodeOptions = SelfOptions & PickRequired<NodeOptions, 'tandem'>;
type LidNodeOptions = SelfOptions;

export default class LidNode extends Node {

Expand Down Expand Up @@ -52,7 +54,7 @@ export default class LidNode extends Node {
const lidHandleNode = new LidHandleNode( options.gripColor, {
right: baseNode.right - HANDLE_RIGHT_INSET,
bottom: baseNode.top + 1,
tandem: options.tandem.createTandem( 'lidHandleNode' )
tandem: options.lidHandleNodeTandem
} );
assert && assert( lidHandleNode.width <= baseNode.width,
`handleNode.width ${lidHandleNode.width} is wider than baseNode.width ${baseNode.width}` );
Expand Down

0 comments on commit b402e80

Please sign in to comment.