-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the number pieces carousel, see #2
- Loading branch information
Showing
5 changed files
with
246 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2019, University of Colorado Boulder | ||
|
||
/** | ||
* The top carousel with number pieces for the Lab screen. | ||
* | ||
* @author Chris Klusendorf (PhET Interactive Simulations) | ||
*/ | ||
define( require => { | ||
'use strict'; | ||
|
||
// modules | ||
const numberPlay = require( 'NUMBER_PLAY/numberPlay' ); | ||
const Carousel = require( 'SUN/Carousel' ); | ||
const Node = require( 'SCENERY/nodes/Node' ); | ||
const StackNodesBox = require( 'FRACTIONS_COMMON/building/view/StackNodesBox' ); | ||
|
||
class LabNumberCarousel extends Carousel { | ||
/** | ||
* @param {Array.<NumberStack>} numberStacks | ||
* @param {number} animationDuration | ||
* @param {function} pressCallback - function( {Event}, {Stack} ) - Called when a press is started. | ||
*/ | ||
constructor( numberStacks, animationDuration, pressCallback ) { | ||
const box = new StackNodesBox( [ | ||
...numberStacks | ||
], pressCallback ); | ||
|
||
super( box.children.map( stack => { | ||
return new Node().addChild( stack ); | ||
} ), { | ||
itemsPerPage: 10, | ||
margin: 14, | ||
spacing: 8, | ||
animationDuration: animationDuration | ||
} ); | ||
|
||
// @private {StackNodesBox} | ||
this.box = box; | ||
} | ||
|
||
/** | ||
* Sets the model positions of our model objects corresponding to their displayed (view) positions. | ||
* @public | ||
* | ||
* @param {ModelViewTransform2} modelViewTransform | ||
*/ | ||
updateModelLocations( modelViewTransform ) { | ||
this.box.updateModelLocations( modelViewTransform, this ); | ||
} | ||
} | ||
|
||
return numberPlay.register( 'LabNumberCarousel', LabNumberCarousel ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters