diff --git a/js/listeners/DragListener.js b/js/listeners/DragListener.js index 00910404b..56a416f4c 100644 --- a/js/listeners/DragListener.js +++ b/js/listeners/DragListener.js @@ -29,11 +29,11 @@ * 3. (optionally) map that to a model location, and (optionally) move that model location to satisfy any constraints of * where the element can be dragged (recomputing the parent/model translation as needed) * 4. Apply the required translation (with a provided drag callback, using the locationProperty, or directly - * transforming the Node if translateNode:true. + * transforming the Node if translateNode:true). * - * TODO: unit tests + * For example usage, see scenery/examples/input.html * - * TODO: add example usage + * TODO: unit tests * * @author Jonathan Olson */ @@ -89,12 +89,12 @@ define( function( require ) { // mapLocation: function( point ) { return dragBounds.closestPointTo( point ); } mapLocation: null, - // {Function|null} - Called as start( event: {Event} ) when the drag is started. This is preferred over passing - // press(), as the drag start hasn't been fully processed at that point. + // {Function|null} - Called as start( event: {Event}, listener: {DragListener} ) when the drag is started. + // This is preferred over passing press(), as the drag start hasn't been fully processed at that point. start: null, - // {Function|null} - Called as end() when the drag is ended. This is preferred over passing release(), as the - // drag start hasn't been fully processed at that point. + // {Function|null} - Called as end( listener: {DragListener} ) when the drag is ended. This is preferred over + // passing release(), as the drag start hasn't been fully processed at that point. end: null }, options ); @@ -168,7 +168,7 @@ define( function( require ) { this.reposition( this.pointer.point ); // Notify after positioning and other changes - this._start && this._start( event ); + this._start && this._start( event, this ); sceneryLog && sceneryLog.InputListener && sceneryLog.pop(); } @@ -196,7 +196,7 @@ define( function( require ) { // Notify after the rest of release is called in order to prevent it from triggering interrupt(). // TODO: Is this a problem that we can't access things like this.pointer here? - this._end && this._end(); + this._end && this._end( this ); sceneryLog && sceneryLog.InputListener && sceneryLog.pop(); }, diff --git a/js/listeners/PressListener.js b/js/listeners/PressListener.js index 946fd4cb1..03c12696f 100644 --- a/js/listeners/PressListener.js +++ b/js/listeners/PressListener.js @@ -45,16 +45,16 @@ define( function( require ) { // cursor of whatever nodes the pointer may be over). pressCursor: 'pointer', - // {Function|null} - Called as press( event: {Event} ) when this listener's node is pressed (typically - // from a down event, but can be triggered by other handlers). + // {Function|null} - Called as press( event: {Event}, listener: {PressListener} ) when this listener's node is + // pressed (typically from a down event, but can be triggered by other handlers). press: null, - // {Function|null} - Called as release() when this listener's node is released (pointer up/cancel or interrupt - // when pressed). + // {Function|null} - Called as release( listener: {PressListener} ) when this listener's node is released + // (pointer up/cancel or interrupt when pressed). release: null, - // {Function|null} - Called as drag( event: {Event} ) when this listener's node is dragged (move events - // on the pointer while pressed). + // {Function|null} - Called as drag( event: {Event}, listener: {PressListener} ) when this listener's node is + //dragged (move events on the pointer while pressed). drag: null, // {Property.} - If provided, this property will be used to track whether this listener's node is @@ -290,7 +290,7 @@ define( function( require ) { this.pointer.cursor = this._pressCursor; // Notify after everything else is set up - this._pressListener && this._pressListener( event ); + this._pressListener && this._pressListener( event, this ); sceneryLog && sceneryLog.InputListener && sceneryLog.pop(); @@ -325,7 +325,7 @@ define( function( require ) { // Notify after the rest of release is called in order to prevent it from triggering interrupt(). // TODO: Is this a problem that we can't access things like this.pointer here? - this._releaseListener && this._releaseListener(); + this._releaseListener && this._releaseListener( this ); sceneryLog && sceneryLog.InputListener && sceneryLog.pop(); }, @@ -344,7 +344,7 @@ define( function( require ) { assert && assert( this.isPressed, 'Can only drag while pressed' ); - this._dragListener && this._dragListener( event ); + this._dragListener && this._dragListener( event, this ); sceneryLog && sceneryLog.InputListener && sceneryLog.pop(); },