Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Aug 24, 2018
1 parent 2557040 commit 9a030a1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions js/NumberControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ define( function( require ) {
endCallback: null, // called when interaction ends, default value set in validateCallbacksAndSetDefault()

// Specific callbacks for each component
sliderStartCallback: null, // called when specific interaction begins
sliderEndCallback: null, // called when specific interaction ends
leftArrowStartCallback: null, // called when specific interaction begins
leftArrowEndCallback: null, // called when specific interaction ends
rightArrowStartCallback: null, // called when specific interaction begins
rightArrowEndCallback: null, // called when specific interaction ends
sliderStartCallback: null, // called when dragging starts on the slider
sliderEndCallback: null, // called when dragging ends on the slider
leftArrowStartCallback: null, // called when left arrow is pressed
leftArrowEndCallback: null, // called when left arrow is released
rightArrowStartCallback: null, // called when right arrow is pressed
rightArrowEndCallback: null, // called when right arrow is released

enabledProperty: new Property( true ), // {Property.<boolean>} is this control enabled?
disabledOpacity: 0.5, // {number} opacity used to make the control look disabled
Expand Down Expand Up @@ -303,15 +303,16 @@ define( function( require ) {
/**
* Validate all of the callback related options. There are two types of callbacks. The "start/endCallback" pair
* are passed into all components in the NumberControl. The second set are start/end callbacks for each individual
* component. This was added to support multitouch in Rutherford Scattering as part of https://github.com/phetsims/rutherford-scattering/issues/128.
* component. This was added to support multitouch in Rutherford Scattering as part of
* https://github.com/phetsims/rutherford-scattering/issues/128.
*
*
* This function mutates the options by initializing general callbacks from null (in the extend call) to a no-op function.
* This function mutates the options by initializing general callbacks from null (in the extend call) to a no-op
* function.
* @param {Object} options
*/
function validateCallbacksAndSetDefault( options ) {

var normalCallbacksPresent = options.startCallback || options.endCallback;
var normalCallbacksPresent = !!( options.startCallback || options.endCallback );

var specificCallbacksPresent = false;
SPECIFIC_COMPONENT_CALLBACK_OPTIONS.forEach( function( callbackOption ) {
Expand All @@ -321,7 +322,8 @@ define( function( require ) {
}
} );

assert && assert( normalCallbacksPresent !== specificCallbacksPresent,
// only general or component specific callbacks are supported
assert && assert( ( !normalCallbacksPresent && !specificCallbacksPresent ) || ( normalCallbacksPresent !== specificCallbacksPresent ),
'Use general callbacks like "startCallback" or specific callbacks like "sliderStartCallback" but not both.' );

// Set here so that we can validate above based on falsey.
Expand Down

0 comments on commit 9a030a1

Please sign in to comment.