Skip to content

Commit

Permalink
Some drag listener fixes + passing listener reference for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Oct 26, 2017
1 parent 92a2872 commit 3c1d5db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions js/listeners/DragListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
},
Expand Down
18 changes: 9 additions & 9 deletions js/listeners/PressListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<Boolean>} - If provided, this property will be used to track whether this listener's node is
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
},
Expand All @@ -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();
},
Expand Down

0 comments on commit 3c1d5db

Please sign in to comment.