Skip to content

Commit

Permalink
made a flag available to tell if track is being dragged, see phetsims…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Dec 28, 2018
1 parent 9ee7275 commit 3c28faa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ define( function( require ) {
// @private mapping between value and track position
this.valueToPosition = new LinearFunction( range.min, range.max, 0, options.trackSize.width, true /* clamp */ );

// @private track
// @public (read-only) {SliderTrack} - track upon which the thumb slides
this.track = new SliderTrack( valueProperty, this.valueToPosition, {

// propagate options that are specific to SliderTrack
Expand Down Expand Up @@ -243,7 +243,7 @@ define( function( require ) {
} );
thumb.addInputListener( thumbInputListener );

// @public (read-only) {Boolean} - flag that indicates whether the thumb is currently being dragged
// @public (read-only) {boolean} - flag that indicates whether the thumb is currently being dragged
this.thumbDragging = false;
var thumbDraggingListener = thumbInputListener.isDraggingProperty.linkAttribute( this, 'thumbDragging' );

Expand Down
5 changes: 5 additions & 0 deletions js/SliderTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ define( function( require ) {
// @public
this.valueToPosition = valueToPosition;

// @public (read-only) {boolean} - a flag that indicates if the track is being dragged by the user
this.trackDragging = false;

// @private - Represents the disabled range of the slider, always visible and always the full range
// of the slider so that when the enabled range changes we see the enabled sub-range on top of the
// full range of the slider.
Expand Down Expand Up @@ -98,6 +101,7 @@ define( function( require ) {
tandem: options.tandem.createTandem( 'trackInputListener' ),

start: function( event, trail ) {
self.trackDragging = true;
if ( self.enabledProperty.get() ) {
options.startDrag();
handleTrackEvent( event, trail );
Expand All @@ -114,6 +118,7 @@ define( function( require ) {
if ( self.enabledProperty.get() ) {
options.endDrag();
}
self.trackDragging = false;
}
} );
this.enabledTrack.addInputListener( trackInputListener );
Expand Down

0 comments on commit 3c28faa

Please sign in to comment.