From ef7400352ad41919f47521080ae88bf37c922fe6 Mon Sep 17 00:00:00 2001 From: zepumph Date: Tue, 16 Feb 2021 15:51:09 -0900 Subject: [PATCH] Create Pointer.isTouchLike(), convert usages of instance Touch to use it, https://github.com/phetsims/scenery/issues/1156 --- js/charges-and-fields/view/ChargedParticleNode.js | 3 +-- js/charges-and-fields/view/ElectricFieldSensorNode.js | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/js/charges-and-fields/view/ChargedParticleNode.js b/js/charges-and-fields/view/ChargedParticleNode.js index d639c693..3ead3506 100644 --- a/js/charges-and-fields/view/ChargedParticleNode.js +++ b/js/charges-and-fields/view/ChargedParticleNode.js @@ -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'; @@ -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. diff --git a/js/charges-and-fields/view/ElectricFieldSensorNode.js b/js/charges-and-fields/view/ElectricFieldSensorNode.js index a7d0fa76..9390d65f 100644 --- a/js/charges-and-fields/view/ElectricFieldSensorNode.js +++ b/js/charges-and-fields/view/ElectricFieldSensorNode.js @@ -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'; @@ -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.