Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Mar 8, 2023
2 parents baf7cc1 + c4fee46 commit c9df03b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions js/view/BodyNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ export default class BodyNode extends ShadedSphereNode {
this.body.escapedProperty.value = body.positionProperty.value.magnitude > options.mapPosition( body.positionProperty.value, this.radius ).magnitude;
} );

let keyboardDragListener: KeyboardDragListener;
let dragMVTListener: ( mvt: ModelViewTransform2 ) => void;

if ( options.draggable ) {
const start = () => {
body.clearPath();
Expand Down Expand Up @@ -167,20 +170,21 @@ export default class BodyNode extends ShadedSphereNode {
bodyDragListener.dispose();
} );

const keyboardDragListener = new KeyboardDragListener(
keyboardDragListener = new KeyboardDragListener(
{
positionProperty: body.positionProperty,
// dragBoundsProperty: dragBoundsProperty,
// dragBoundsProperty: dragBoundsProperty, //REVIEW: Why commented out?
transform: modelViewTransformProperty.value,
dragDelta: 8,
shiftDragDelta: 2.5,
start: start,
end: end,
mapPosition: map
} );
modelViewTransformProperty.link( modelViewTransform => {
dragMVTListener = modelViewTransform => {
keyboardDragListener.transform = modelViewTransform;
} );
};
modelViewTransformProperty.link( dragMVTListener );
this.addInputListener( keyboardDragListener );
}

Expand Down Expand Up @@ -232,6 +236,8 @@ export default class BodyNode extends ShadedSphereNode {


this.disposeBodyNode = () => {
keyboardDragListener && keyboardDragListener.dispose();
dragMVTListener && modelViewTransformProperty.unlink( dragMVTListener );
positionMultilink.dispose();
radiusMultilink.dispose();
this.body.collidedEmitter.removeListener( bodyCollisionListener );
Expand Down

0 comments on commit c9df03b

Please sign in to comment.