Skip to content

Commit

Permalink
dragBounds => dragBoundsProperty, see phetsims/scenery#131
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Apr 26, 2018
1 parent 9493cf2 commit 0ff3618
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
7 changes: 1 addition & 6 deletions js/charges-and-fields/view/ChargedParticleNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ define( function( require ) {
applyOffset: false,
locationProperty: chargedParticle.positionProperty,
tandem: tandem.createTandem( 'dragListener' ),
dragBounds: availableModelBoundsProperty.get(),
dragBoundsProperty: availableModelBoundsProperty,
transform: modelViewTransform,
canStartPress: function() { return !chargedParticle.animationTween; },
isUserControlledProperty: chargedParticle.isUserControlledProperty,
Expand All @@ -76,10 +76,6 @@ define( function( require ) {
}
} );

// readjust the dragBounds of the movable drag handler when the screen is resized
var dragBoundsListener = self.movableDragHandler.setDragBounds.bind( self.movableDragHandler );
availableModelBoundsProperty.link( dragBoundsListener );

// Conditionally hook up the input handling (and cursor) when the charged particle is interactive.
var isDragListenerAttached = false;

Expand All @@ -103,7 +99,6 @@ define( function( require ) {
chargedParticle.isInteractiveProperty.link( isInteractiveListener );

this.disposeChargedParticleNode = function() {
availableModelBoundsProperty.unlink( dragBoundsListener );
chargedParticle.positionProperty.unlink( positionListener );
chargedParticle.isInteractiveProperty.unlink( isInteractiveListener );
this.movableDragHandler.dispose();
Expand Down
9 changes: 1 addition & 8 deletions js/charges-and-fields/view/ElectricFieldSensorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ define( function( require ) {
applyOffset: false,
locationProperty: electricFieldSensor.positionProperty,
tandem: tandem.createTandem( 'dragListener' ),
dragBounds: availableModelBoundsProperty.value,
dragBoundsProperty: availableModelBoundsProperty,
transform: modelViewTransform,
canStartPress: function() { return !electricFieldSensor.animationTween; },
isUserControlledProperty: electricFieldSensor.isUserControlledProperty,
Expand Down Expand Up @@ -238,12 +238,6 @@ define( function( require ) {
};
electricFieldSensor.isInteractiveProperty.link( isInteractiveListener );

var availableModelBoundsPropertyListener = function( bounds ) {
self.movableDragHandler.setDragBounds( bounds );
};

availableModelBoundsProperty.link( availableModelBoundsPropertyListener );

this.availableModelBoundsProperty = availableModelBoundsProperty;

this.disposeElectricFieldSensorNode = function() {
Expand All @@ -256,7 +250,6 @@ define( function( require ) {
isPlayAreaChargedProperty.unlink( isPlayAreaChargedListener );
isDirectionLabelVisibleDerivedProperty.unlink( isDirectionLabelVisibleListener );
isDirectionLabelVisibleDerivedProperty.dispose();
availableModelBoundsProperty.unlink( availableModelBoundsPropertyListener );
this.movableDragHandler.dispose();
fieldStrengthLabel.dispose();
directionLabel.dispose();
Expand Down
7 changes: 1 addition & 6 deletions js/charges-and-fields/view/ElectricPotentialSensorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ define( function( require ) {
this.movableDragHandler = new DragListener( {
locationProperty: electricPotentialSensor.positionProperty,
tandem: tandem.createTandem( 'dragListener' ),
dragBounds: availableModelBoundsProperty.get(),
dragBoundsProperty: availableModelBoundsProperty,
transform: modelViewTransform,
isUserControlledProperty: this.isUserControlledProperty,
end: function( event, listener ) {
Expand All @@ -267,11 +267,6 @@ define( function( require ) {
// When dragging, move the electric potential sensor
self.addInputListener( this.movableDragHandler );

//no need to unlink, the sensor is present for the lifetime of the simulation.
availableModelBoundsProperty.link( function( bounds ) {
self.movableDragHandler.setDragBounds( bounds );
} );

// Show/Hide this node
// no need to unlink, stays for the lifetime of the simulation
electricPotentialSensor.isActiveProperty.linkAttribute( this, 'visible' );
Expand Down

0 comments on commit 0ff3618

Please sign in to comment.