diff --git a/js/common/model/Dropper.ts b/js/common/model/Dropper.ts index 2e408360..1ecc4bc3 100644 --- a/js/common/model/Dropper.ts +++ b/js/common/model/Dropper.ts @@ -9,11 +9,11 @@ import BooleanProperty from '../../../../axon/js/BooleanProperty.js'; import NumberProperty from '../../../../axon/js/NumberProperty.js'; import Property from '../../../../axon/js/Property.js'; -import Bounds2 from '../../../../dot/js/Bounds2.js'; import Vector2 from '../../../../dot/js/Vector2.js'; import optionize from '../../../../phet-core/js/optionize.js'; +import PickRequired from '../../../../phet-core/js/types/PickRequired.js'; +import { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js'; import phScale from '../../phScale.js'; -import PHMovable, { PHMovableOptions } from './PHMovable.js'; import Solute from './Solute.js'; type SelfOptions = { @@ -25,10 +25,11 @@ type SelfOptions = { visible?: boolean; // is the dropper visible? }; -type DropperOptions = SelfOptions & PHMovableOptions; +type DropperOptions = SelfOptions & PickRequired; -export default class Dropper extends PHMovable { +export default class Dropper { + public readonly position: Vector2; public readonly soluteProperty: Property; public readonly flowRateProperty: Property; public readonly isDispensingProperty: Property; @@ -38,9 +39,9 @@ export default class Dropper extends PHMovable { // See https://github.com/phetsims/ph-scale/issues/178 public readonly visibleProperty: Property; - public constructor( solute: Solute, solutes: Solute[], position: Vector2, dragBounds: Bounds2, providedOptions: DropperOptions ) { + public constructor( solute: Solute, solutes: Solute[], position: Vector2, providedOptions: DropperOptions ) { - const options = optionize()( { + const options = optionize()( { // SelfOptions flowRate: 0, @@ -48,15 +49,10 @@ export default class Dropper extends PHMovable { dispensing: false, empty: false, enabled: true, - visible: true, - - // PHMovableOptions - positionPropertyOptions: { - phetioHighFrequency: true - } + visible: true }, providedOptions ); - super( position, dragBounds, options ); + this.position = position; this.soluteProperty = new Property( solute, { validValues: solutes, @@ -105,8 +101,7 @@ export default class Dropper extends PHMovable { } ); } - public override reset(): void { - super.reset(); + public reset(): void { this.soluteProperty.reset(); this.isDispensingProperty.reset(); this.enabledProperty.reset(); diff --git a/js/common/model/PHModel.ts b/js/common/model/PHModel.ts index 083357bd..ef7eb1b7 100644 --- a/js/common/model/PHModel.ts +++ b/js/common/model/PHModel.ts @@ -8,7 +8,6 @@ import BooleanProperty from '../../../../axon/js/BooleanProperty.js'; import Property from '../../../../axon/js/Property.js'; -import Bounds2 from '../../../../dot/js/Bounds2.js'; import Vector2 from '../../../../dot/js/Vector2.js'; import optionize from '../../../../phet-core/js/optionize.js'; import PickRequired from '../../../../phet-core/js/types/PickRequired.js'; @@ -100,11 +99,9 @@ export default class PHModel implements TModel { this.beaker = new Beaker( PHScaleConstants.BEAKER_POSITION ); const yDropper = this.beaker.position.y - this.beaker.size.height - 15; - this.dropper = new Dropper( Solute.WATER, this.solutes, - new Vector2( this.beaker.position.x - 50, yDropper ), - new Bounds2( this.beaker.left + 40, yDropper, this.beaker.right - 200, yDropper ), { - tandem: options.tandem.createTandem( 'dropper' ) - } ); + this.dropper = new Dropper( Solute.WATER, this.solutes, new Vector2( this.beaker.position.x - 50, yDropper ), { + tandem: options.tandem.createTandem( 'dropper' ) + } ); this.solution = options.createSolution( this.dropper.soluteProperty, this.beaker.volume, options.tandem.createTandem( 'solution' ) ); diff --git a/js/common/view/DropperFluidNode.ts b/js/common/view/DropperFluidNode.ts index bd9ab758..fa741f5a 100644 --- a/js/common/view/DropperFluidNode.ts +++ b/js/common/view/DropperFluidNode.ts @@ -29,16 +29,15 @@ export default class DropperFluidNode extends Rectangle { // shape if ( dropper.flowRateProperty.value > 0 ) { - this.setRect( -tipWidth / 2, 0, tipWidth, beaker.position.y - dropper.positionProperty.value.y ); + this.setRect( -tipWidth / 2, 0, tipWidth, beaker.position.y - dropper.position.y ); } else { this.setRect( 0, 0, 0, 0 ); } // move this node to the dropper's position - this.translation = modelViewTransform.modelToViewPosition( dropper.positionProperty.value ); + this.translation = modelViewTransform.modelToViewPosition( dropper.position ); }; - dropper.positionProperty.link( updateShapeAndPosition ); dropper.flowRateProperty.link( updateShapeAndPosition ); // set color to match solute diff --git a/js/common/view/PHDropperNode.ts b/js/common/view/PHDropperNode.ts index 638c5406..e3a0e8ba 100644 --- a/js/common/view/PHDropperNode.ts +++ b/js/common/view/PHDropperNode.ts @@ -8,12 +8,10 @@ * @author Chris Malley (PixelZoom, Inc.) */ -import Property from '../../../../axon/js/Property.js'; import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js'; import PickRequired from '../../../../phet-core/js/types/PickRequired.js'; import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js'; import EyeDropperNode, { EyeDropperNodeOptions } from '../../../../scenery-phet/js/EyeDropperNode.js'; -import { DragListener, InteractiveHighlighting } from '../../../../scenery/js/imports.js'; import phScale from '../../phScale.js'; import Dropper from '../model/Dropper.js'; @@ -21,7 +19,7 @@ type SelfOptions = EmptySelfOptions; type PHDropperNodeOptions = SelfOptions & PickRequired; -export default class PHDropperNode extends InteractiveHighlighting( EyeDropperNode ) { +export default class PHDropperNode extends EyeDropperNode { public constructor( dropper: Dropper, modelViewTransform: ModelViewTransform2, providedOptions: PHDropperNodeOptions ) { @@ -39,30 +37,12 @@ export default class PHDropperNode extends InteractiveHighlighting( EyeDropperNo super( options ); // position - dropper.positionProperty.link( position => { - this.translation = modelViewTransform.modelToViewPosition( position ); - } ); + this.translation = modelViewTransform.modelToViewPosition( dropper.position ); // change fluid color when the solute changes dropper.soluteProperty.link( solute => { this.setFluidColor( solute.stockColor ); } ); - - // dilate touch area - this.touchArea = this.localBounds.dilatedX( 0.25 * this.width ); - - // move the dropper - this.addInputListener( new DragListener( { - useInputListenerCursor: true, - positionProperty: dropper.positionProperty, - dragBoundsProperty: new Property( dropper.dragBounds ), - transform: modelViewTransform, - tandem: options.tandem.createTandem( 'dragListener' ), - phetioEnabledPropertyInstrumented: true // see https://github.com/phetsims/ph-scale/issues/263 - } ) ); - - // NOTE: Moving the dropper via the keyboard is not necessary. - // See https://github.com/phetsims/ph-scale/issues/252 } } diff --git a/js/micro/model/MicroModel.ts b/js/micro/model/MicroModel.ts index f37f6355..01fc4a88 100644 --- a/js/micro/model/MicroModel.ts +++ b/js/micro/model/MicroModel.ts @@ -7,7 +7,6 @@ * @author Chris Malley (PixelZoom, Inc.) */ -import Bounds2 from '../../../../dot/js/Bounds2.js'; import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js'; import PickRequired from '../../../../phet-core/js/types/PickRequired.js'; import PHModel, { PHModelOptions } from '../../common/model/PHModel.js'; @@ -32,10 +31,6 @@ export default class MicroModel extends PHModel { }, providedOptions ); super( options ); - - // adjust the drag bounds of the dropper to account for different user-interface constraints - const yDropper = this.dropper.positionProperty.value.y; - this.dropper.dragBounds = new Bounds2( this.beaker.left + 120, yDropper, this.beaker.right - 170, yDropper ); } }