Skip to content

Commit

Permalink
refactor so ruler drag bounds are calculated in the screen view, phet…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 18, 2019
1 parent 7f114f2 commit 695f0a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js/common/view/CoulombsLawCommonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ define( require => {
// @private
this.modelViewTransform = modelViewTransform;

// ruler drag bounds (in model coordinate frame) - assumes a single point scale inverted Y mapping
const halfModelHeight = modelViewTransform.viewToModelDeltaY( this.layoutBounds.height / 2 );
const minX = coulombsLawModel.leftObjectBoundary;
const minY = halfModelHeight; // bottom bound because Y is inverted
const maxX = coulombsLawModel.rightObjectBoundary;
const maxY = -halfModelHeight; // top bound because Y is inverted

// create and add macro ruler
const coulombsLawRuler = new ISLCRulerNode(
coulombsLawModel,
this.layoutBounds.height,
coulombsLawModel.rulerPositionProperty,
new Bounds2( minX, minY, maxX, maxY ),
this.modelViewTransform,
() => coulombsLawModel.object1.positionProperty.value, // wrap this in a closure instead of exposing this all to the ruler.
{ getRulerGrabbedAlertable: () => '' }, // describer stub
tandem.createTandem( 'ruler' ),
_.pick( options, [
Expand Down

0 comments on commit 695f0a2

Please sign in to comment.