Skip to content

Commit

Permalink
fix dragBoundsProperty and cursor for electromagnet.coil.backgroundNo…
Browse files Browse the repository at this point in the history
…de, #169
  • Loading branch information
pixelzoom committed May 22, 2024
1 parent 67cce12 commit a5f6521
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions js/common/view/ElectromagnetNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class ElectromagnetNode extends FELMovableNode {
const options = optionize<ElectromagnetNodeOptions, SelfOptions, FELMovableNodeOptions>()( {}, providedOptions );

const coilNode = new CoilNode( electromagnet.coil, electromagnet, {
dragBoundsProperty: options.dragBoundsProperty,
tandem: options.tandem.createTandem( 'coilNode' )
} );

Expand Down
10 changes: 9 additions & 1 deletion js/common/view/FELScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import isSettingPhetioStateProperty from '../../../../tandem/js/isSettingPhetioStateProperty.js';
import FELQueryParameters from '../FELQueryParameters.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import BarMagnetNode from './BarMagnetNode.js';
import ElectromagnetNode from './ElectromagnetNode.js';

type SelfOptions = {

Expand Down Expand Up @@ -185,7 +187,7 @@ export default class FELScreenView extends ScreenView {
panelsBoundsProperty: TReadOnlyProperty<Bounds2>,
magnetPositionProperty: Property<Vector2>,
pickupCoilPositionProperty: Property<Vector2>,
magnetNode: Node,
magnetNode: BarMagnetNode | ElectromagnetNode,
pickupCoilNode: PickupCoilNode
): void {
Multilink.multilink( [ lockedToAxisProperty, panelsBoundsProperty ], ( lockToAxis, panelsBounds ) => {
Expand All @@ -209,6 +211,9 @@ export default class FELScreenView extends ScreenView {

// Change the cursors to indicate that drag direction is constrained to horizontal.
magnetNode.cursor = 'ew-resize';
if ( magnetNode instanceof ElectromagnetNode ) {
magnetNode.backgroundNode.cursor = 'ew-resize';
}
pickupCoilNode.cursor = 'ew-resize';
pickupCoilNode.backgroundNode.cursor = 'ew-resize';
}
Expand All @@ -220,6 +225,9 @@ export default class FELScreenView extends ScreenView {

// Restore cursors.
magnetNode.cursor = 'pointer';
if ( magnetNode instanceof ElectromagnetNode ) {
magnetNode.backgroundNode.cursor = 'pointer';
}
pickupCoilNode.cursor = 'pointer';
pickupCoilNode.backgroundNode.cursor = 'pointer';
}
Expand Down

0 comments on commit a5f6521

Please sign in to comment.