Skip to content

Commit

Permalink
assertions, doc, #453
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Malley <[email protected]>
  • Loading branch information
pixelzoom committed Jan 24, 2019
1 parent d874df5 commit c8970ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions js/ComboBoxListBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ define( require => {

}, options );

assert && assert( options.xMargin > 0 && options.yMargin > 0,
'margins must be > 0, xMargin=' + options.xMargin + ', yMargin=' + options.yMargin );

//TODO sun#462 replace fireEmitter and selectionListener with a standard scenery listener
const firedEmitter = new Emitter( {
argumentTypes: [ { validValue: Event } ],
Expand Down
12 changes: 6 additions & 6 deletions js/ComboBoxListItemNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ define( require => {

/**
* @param {ComboBoxItem} item
* @param {number} width
* @param {number} height
* @param {number} highlightWidth
* @param {number} highlightHeight
* @param {Object} [options]
*/
constructor( item, width, height, options ) {
constructor( item, highlightWidth, highlightHeight, options ) {

assert && assert( item instanceof ComboBoxItem );

options = _.extend( {

cursor: 'pointer',
align: 'left',
xMargin: 6,
xMargin: 6, // margin between the item and the highlight edge
highlightFill: 'rgb( 245, 245, 245 )', // {Color|string} highlight behind the item
highlightCornerRadius: 4, // {number} corner radius for the highlight

Expand All @@ -53,14 +53,14 @@ define( require => {
options.innerContent = item.a11yLabel;

// Highlight that is shown when the pointer is over this item. This is not the a11y focus rectangle.
const highlightRectangle = new Rectangle( 0, 0, width, height, {
const highlightRectangle = new Rectangle( 0, 0, highlightWidth, highlightHeight, {
cornerRadius: options.highlightCornerRadius
} );

// Wrapper for the item's Node. Do not transform item.node because it is shared with ComboBoxButton!
const itemNodeWrapper = new Node( {
children: [ item.node ],
centerY: height / 2
centerY: highlightHeight / 2
} );
if ( options.align === 'left' ) {
itemNodeWrapper.left = highlightRectangle.left + options.xMargin;
Expand Down

0 comments on commit c8970ee

Please sign in to comment.