diff --git a/js/NumberControl.js b/js/NumberControl.js index 71ec9eb45..647827b43 100644 --- a/js/NumberControl.js +++ b/js/NumberControl.js @@ -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.} is this control enabled? disabledOpacity: 0.5, // {number} opacity used to make the control look disabled @@ -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 ) { @@ -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.