From 623f7d83b71b92acb18358d1b6d8ea5fcb3823c2 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Thu, 5 Mar 2015 22:40:13 -0700 Subject: [PATCH] Added arch support, see #161 --- js/HSlider.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/js/HSlider.js b/js/HSlider.js index 997ce3c9..cb3caa7f 100644 --- a/js/HSlider.js +++ b/js/HSlider.js @@ -111,7 +111,7 @@ define( function( require ) { // Make the thumb focusable for keyboard accessibility thumb.focusable = true; - + thisSlider.thumb = thumb; // must be disposed of thumb.centerY = thisSlider.track.centerY; thisSlider.addChild( thumb ); @@ -134,25 +134,41 @@ define( function( require ) { // update value when thumb is dragged var thumbHandler = new SimpleDragHandler( { - clickXOffset: 0, // x-offset between initial click and thumb's origin + + // x-offset between initial click and thumb's origin + clickXOffset: 0, + allowTouchSnag: true, + start: function( event, trail ) { if ( options.enabledProperty.get() ) { + var archID = arch && arch.start( 'user', thisSlider.componentID, thisSlider.componentType, 'dragStart', { value: valueProperty.get() } ); options.startDrag(); + + var transform = trail.subtrailTo( thisSlider ).getTransform(); + this.clickXOffset = transform.inversePosition2( event.pointer.point ).x - thumb.x; + + arch && arch.end( archID ); } - var transform = trail.subtrailTo( thisSlider ).getTransform(); - this.clickXOffset = transform.inversePosition2( event.pointer.point ).x - thumb.x; }, + drag: function( event, trail ) { if ( options.enabledProperty.get() ) { var transform = trail.subtrailTo( thisSlider ).getTransform(); // we only want the transform to our parent var x = transform.inversePosition2( event.pointer.point ).x - this.clickXOffset; - valueProperty.set( thisSlider.valueToPosition.inverse( x ) ); + var newValue = thisSlider.valueToPosition.inverse( x ); + + var archID = arch && arch.start( 'user', thisSlider.componentID, thisSlider.componentType, 'drag', { value: newValue } ); + valueProperty.set( newValue ); + arch && arch.end( archID ); } }, + end: function() { if ( options.enabledProperty.get() ) { + var archID = arch && arch.start( 'user', thisSlider.componentID, thisSlider.componentType, 'dragEnd', { value: valueProperty.get() } ); options.endDrag(); + arch && arch.end( archID ); } } } );