Skip to content

Commit

Permalink
handle maxWidth for undefined slope labels, #114
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Feb 5, 2019
1 parent 26689cc commit b5d381f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion js/pointslope/view/PointSlopeEquationNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ define( function( require ) {
x1Node = new DynamicValueNode( x1Property, _.extend( { absoluteValue: true }, staticOptions ) );
}
var xRightParenNode = new Text( ')', staticOptions );
var slopeUndefinedNode = new RichText( '?', staticOptions );
var slopeUndefinedNode = new RichText( '?', _.extend( {}, staticOptions, {
maxWidth: options.maxWidth // see #114
} ) );

// add all nodes, we'll set which ones are visible bases on desired simplification
self.children = [
Expand Down
12 changes: 6 additions & 6 deletions js/slope/view/SlopeEquationNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,14 @@ define( function( require ) {

// allocate nodes needed to represent all simplified forms
var slopeIsNode = new Text( slopeIsString, textOptions );
var undefinedNode = new Text( undefinedString, textOptions );
var minusSignNode = new MinusNode( { size: this.signLineSize } );
var riseNode = new Text( '?', textOptions );
var runNode = new Text( '?', textOptions );
var fractionLineNode = new scenery.Line( 0, 0, 1, 0, { lineWidth: this.fractionLineThickness } );

// add all nodes, we'll set which ones are visible bases on desired simplification
assert && assert( this.getChildrenCount() === 0, 'supertype has unexpected children' );
this.children = [ slopeIsNode, undefinedNode, minusSignNode, riseNode, runNode, fractionLineNode ];
this.children = [ slopeIsNode, minusSignNode, riseNode, runNode, fractionLineNode ];

// update visibility, layout and properties of nodes to match the current line
var update = function( line ) {
Expand All @@ -400,10 +399,11 @@ define( function( require ) {

if ( line.undefinedSlope() ) {
// 'undefined'
undefinedNode.visible = true;
undefinedNode.fill = lineColor;
undefinedNode.left = slopeIsNode.right + self.relationalOperatorXSpacing;
undefinedNode.y = slopeIsNode.y;
riseNode.visible = true;
riseNode.text = undefinedString;
riseNode.fill = lineColor;
riseNode.left = slopeIsNode.right + self.relationalOperatorXSpacing;
riseNode.y = slopeIsNode.y;
}
else if ( line.getSlope() === 0 ) {
// 0
Expand Down
4 changes: 3 additions & 1 deletion js/slopeintercept/view/SlopeInterceptEquationNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ define( function( require ) {
}
var yInterceptDenominatorNode = new DynamicValueNode( yInterceptDenominatorProperty, _.extend( { absoluteValue: true }, staticOptions ) );
var yInterceptFractionLineNode = new scenery.Line( 0, 0, maxSlopePickerWidth, 0, fractionLineOptions );
var slopeUndefinedNode = new RichText( '?', staticOptions );
var slopeUndefinedNode = new RichText( '?', _.extend( {}, staticOptions, {
maxWidth: options.maxWidth // see #114
} ) );

// add all nodes, we'll set which ones are visible bases on desired simplification
self.children = [ yNode, equalsNode, slopeMinusSignNode, riseNode, runNode, slopeFractionLineNode, xNode, plusNode, minusNode,
Expand Down

0 comments on commit b5d381f

Please sign in to comment.