Skip to content

Commit

Permalink
minor refactor, phetsims/my-solar-system#86
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Mar 3, 2023
1 parent fababc9 commit 6b8965e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions js/view/BodyNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,26 @@ export default class BodyNode extends ShadedSphereNode {
} );

if ( options.draggable ) {
const startEnd = {
start: () => {
body.clearPath();
body.userControlledPositionProperty.value = true;
this.grabClip.play();
},
end: () => {
body.userControlledPositionProperty.value = false;
this.releaseClip.play();
}
const start = () => {
body.clearPath();
body.userControlledPositionProperty.value = true;
this.grabClip.play();
};
const end = () => {
body.userControlledPositionProperty.value = false;
this.releaseClip.play();
};
const map = ( point: Vector2 ) => {
return options.mapPosition( point, this.radius );
};

const bodyDragListener = new DragListener( {
positionProperty: body.positionProperty,
canStartPress: () => !body.userControlledPositionProperty.value,
mapPosition: point => {
return options.mapPosition( point, this.radius );
},
mapPosition: map,
transform: modelViewTransformProperty,
...startEnd
start: start,
end: end
} );
this.addInputListener( bodyDragListener );
this.disposeEmitter.addListener( () => {
Expand All @@ -171,7 +171,8 @@ export default class BodyNode extends ShadedSphereNode {
transform: modelViewTransformProperty.value,
dragDelta: 8,
shiftDragDelta: 2.5,
...startEnd
start: start,
end: end
} );
modelViewTransformProperty.link( modelViewTransform => {
keyboardDragListener.transform = modelViewTransform;
Expand Down

0 comments on commit 6b8965e

Please sign in to comment.