Skip to content

Commit

Permalink
Create Pointer.isTouchLike(), convert usages of instance Touch to use…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Feb 17, 2021
1 parent 3e4d958 commit ef74003
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions js/charges-and-fields/view/ChargedParticleNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import Vector2 from '../../../../dot/js/Vector2.js';
import Touch from '../../../../scenery/js/input/Touch.js';
import DragListener from '../../../../scenery/js/listeners/DragListener.js';
import Node from '../../../../scenery/js/nodes/Node.js';
import chargesAndFields from '../../chargesAndFields.js';
Expand Down Expand Up @@ -60,7 +59,7 @@ class ChargedParticleNode extends ChargedParticleRepresentationNode {
transform: modelViewTransform,
canStartPress: () => !chargedParticle.animationTween,
offsetPosition: ( point, listener ) => {
return listener.pointer instanceof Touch ? new Vector2( 0, -2 * CIRCLE_RADIUS ) : Vector2.ZERO;
return listener.pointer.isTouchLike() ? new Vector2( 0, -2 * CIRCLE_RADIUS ) : Vector2.ZERO;
},
start: ( event, listener ) => {
// Move the chargedParticle to the front of this layer when grabbed by the user.
Expand Down
5 changes: 2 additions & 3 deletions js/charges-and-fields/view/ElectricFieldSensorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import merge from '../../../../phet-core/js/merge.js';
import StringUtils from '../../../../phetcommon/js/util/StringUtils.js';
import ArrowNode from '../../../../scenery-phet/js/ArrowNode.js';
import Touch from '../../../../scenery/js/input/Touch.js';
import DragListener from '../../../../scenery/js/listeners/DragListener.js';
import Node from '../../../../scenery/js/nodes/Node.js';
import Text from '../../../../scenery/js/nodes/Text.js';
import chargesAndFieldsStrings from '../../chargesAndFieldsStrings.js';
import chargesAndFields from '../../chargesAndFields.js';
import chargesAndFieldsStrings from '../../chargesAndFieldsStrings.js';
import ChargesAndFieldsColorProfile from '../ChargesAndFieldsColorProfile.js';
import ChargesAndFieldsConstants from '../ChargesAndFieldsConstants.js';
import ElectricFieldSensorRepresentationNode from './ElectricFieldSensorRepresentationNode.js';
Expand Down Expand Up @@ -194,7 +193,7 @@ class ElectricFieldSensorNode extends ElectricFieldSensorRepresentationNode {
transform: modelViewTransform,
canStartPress: () => !electricFieldSensor.animationTween,
offsetPosition: ( point, listener ) => {
return listener.pointer instanceof Touch ? new Vector2( 0, -2 * ChargesAndFieldsConstants.ELECTRIC_FIELD_SENSOR_CIRCLE_RADIUS ) : Vector2.ZERO;
return listener.pointer.isTouchLike() ? new Vector2( 0, -2 * ChargesAndFieldsConstants.ELECTRIC_FIELD_SENSOR_CIRCLE_RADIUS ) : Vector2.ZERO;
},
start: ( event, listener ) => {
// Move the sensor to the front of this layer when grabbed by the user.
Expand Down

0 comments on commit ef74003

Please sign in to comment.