Skip to content

Commit

Permalink
factor out PLATE_X_OFFSET #66
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 19, 2017
1 parent 692e4fa commit 700e982
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions js/threeatoms/view/ThreeAtomsScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ define( function( require ) {
var ThreeAtomsViewProperties = require( 'MOLECULE_POLARITY/threeatoms/view/ThreeAtomsViewProperties' );
var TriatomicMoleculeNode = require( 'MOLECULE_POLARITY/threeatoms/view/TriatomicMoleculeNode' );

// constants
var PLATE_X_OFFSET = 300; // x offset of E-field plates from molecule's center, determined empirically, see #66

/**
* @param {ThreeAtomsModel} model
* @constructor
Expand Down Expand Up @@ -78,14 +81,13 @@ define( function( require ) {

var moleculeX = model.molecule.location.x;
var moleculeY = model.molecule.location.y;
var plateXOffset = 300; // x offset from molecule, determined empirically

// to left of molecule, vertically centered
negativePlateNode.right = moleculeX - plateXOffset;
negativePlateNode.right = moleculeX - PLATE_X_OFFSET;
negativePlateNode.y = moleculeY - ( negativePlateNode.plateHeight / 2 );

// to right of molecule, vertically centered
positivePlateNode.left = moleculeX + plateXOffset;
positivePlateNode.left = moleculeX + PLATE_X_OFFSET;
positivePlateNode.y = moleculeY - ( positivePlateNode.plateHeight / 2 );

// centered below molecule
Expand Down
8 changes: 5 additions & 3 deletions js/twoatoms/view/TwoAtomsScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ define( function( require ) {
var SurfaceType = require( 'MOLECULE_POLARITY/common/view/SurfaceType' );
var TwoAtomsViewControls = require( 'MOLECULE_POLARITY/twoatoms/view/TwoAtomsViewControls' );
var TwoAtomsViewProperties = require( 'MOLECULE_POLARITY/twoatoms/view/TwoAtomsViewProperties' );

// constants
var PLATE_X_OFFSET = 250; // x offset of E-field plates from molecule's center, determined empirically, see #66

/**
* @param {TwoAtomsModel} model
Expand Down Expand Up @@ -88,14 +91,13 @@ define( function( require ) {

var moleculeX = model.molecule.location.x;
var moleculeY = model.molecule.location.y;
var plateXOffset = 250; // x offset from molecule, determined empirically

// to left of molecule, vertically centered
negativePlateNode.right = moleculeX - plateXOffset;
negativePlateNode.right = moleculeX - PLATE_X_OFFSET;
negativePlateNode.y = moleculeY - ( negativePlateNode.plateHeight / 2 );

// to right of molecule, vertically centered
positivePlateNode.left = moleculeX + plateXOffset;
positivePlateNode.left = moleculeX + PLATE_X_OFFSET;
positivePlateNode.y = moleculeY - ( positivePlateNode.plateHeight / 2 );

// centered below molecule
Expand Down

0 comments on commit 700e982

Please sign in to comment.