Skip to content

Commit

Permalink
ES6 module migration, see phetsims/chipper#875
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 23, 2020
1 parent 77d08b6 commit 7b62a06
Showing 1 changed file with 46 additions and 49 deletions.
95 changes: 46 additions & 49 deletions js/SpanNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,51 @@
*
* @author Sam Reid (PhET Interactive Simulations)
*/
define( require => {
'use strict';

// modules
const Node = require( 'SCENERY/nodes/Node' );
const ArrowNode = require( 'SCENERY_PHET/ArrowNode' );
const griddle = require( 'GRIDDLE/griddle' );
const Line = require( 'SCENERY/nodes/Line' );
const VBox = require( 'SCENERY/nodes/VBox' );

class SpanNode extends Node {

/**
* @param {Node} scaleIndicatorTextNode
* @param {number} width
* @param {Object} [options]
*/
constructor( scaleIndicatorTextNode, width, options ) {
super();

// Create double-headed arrow with bars to show the time between gridlines
const createBar = centerX => new Line( 0, 0, 0, 6, { stroke: 'white', centerX: centerX } );
const leftBar = createBar( 0 );
const rightBar = createBar( width );
const arrowNode = new ArrowNode( leftBar.right + 1, leftBar.centerY, rightBar.left - 1, rightBar.centerY, {
fill: 'white',
stroke: 'white',
doubleHead: true,
headHeight: 3,
headWidth: 3.5,
tailWidth: 0.5
} );
const arrowWithBars = new Node( {
children: [ leftBar, rightBar, arrowNode ]
} );

// Prevent the scale indicator text from being wider than the corresponding arrow
scaleIndicatorTextNode.maxWidth = arrowWithBars.width;

const lengthScaleIndicatorNode = new VBox( {
spacing: -2,
children: [ arrowWithBars, scaleIndicatorTextNode ]
} );
this.children = [ arrowNode, lengthScaleIndicatorNode ];

this.mutate( options );
}

import ArrowNode from '../../scenery-phet/js/ArrowNode.js';
import Line from '../../scenery/js/nodes/Line.js';
import Node from '../../scenery/js/nodes/Node.js';
import VBox from '../../scenery/js/nodes/VBox.js';
import griddle from './griddle.js';

class SpanNode extends Node {

/**
* @param {Node} scaleIndicatorTextNode
* @param {number} width
* @param {Object} [options]
*/
constructor( scaleIndicatorTextNode, width, options ) {
super();

// Create double-headed arrow with bars to show the time between gridlines
const createBar = centerX => new Line( 0, 0, 0, 6, { stroke: 'white', centerX: centerX } );
const leftBar = createBar( 0 );
const rightBar = createBar( width );
const arrowNode = new ArrowNode( leftBar.right + 1, leftBar.centerY, rightBar.left - 1, rightBar.centerY, {
fill: 'white',
stroke: 'white',
doubleHead: true,
headHeight: 3,
headWidth: 3.5,
tailWidth: 0.5
} );
const arrowWithBars = new Node( {
children: [ leftBar, rightBar, arrowNode ]
} );

// Prevent the scale indicator text from being wider than the corresponding arrow
scaleIndicatorTextNode.maxWidth = arrowWithBars.width;

const lengthScaleIndicatorNode = new VBox( {
spacing: -2,
children: [ arrowWithBars, scaleIndicatorTextNode ]
} );
this.children = [ arrowNode, lengthScaleIndicatorNode ];

this.mutate( options );
}
}

return griddle.register( 'SpanNode', SpanNode );
} );
griddle.register( 'SpanNode', SpanNode );
export default SpanNode;

0 comments on commit 7b62a06

Please sign in to comment.