From 7b62a0628c9ada9ab7923fea716dafa618cecb30 Mon Sep 17 00:00:00 2001 From: samreid Date: Thu, 27 Feb 2020 11:46:44 -0700 Subject: [PATCH] ES6 module migration, see https://github.com/phetsims/chipper/issues/875 --- js/SpanNode.js | 95 ++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 49 deletions(-) diff --git a/js/SpanNode.js b/js/SpanNode.js index c4ba980..12dd33c 100644 --- a/js/SpanNode.js +++ b/js/SpanNode.js @@ -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 ); -} ); \ No newline at end of file +griddle.register( 'SpanNode', SpanNode ); +export default SpanNode; \ No newline at end of file