Skip to content

Commit

Permalink
No-op on drag with non-pressed drag/press listener, see phetsims/vect…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Jul 17, 2024
1 parent bb836b6 commit ec4a0e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions js/listeners/DragListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ export default class DragListener extends PressListener implements TInputListene
return;
}

// If we got interrupted while events were queued up, we MAY get a drag when not pressed. We can ignore this.
if ( !this.isPressed ) {
return;
}

sceneryLog && sceneryLog.InputListener && sceneryLog.InputListener( 'DragListener drag' );
sceneryLog && sceneryLog.InputListener && sceneryLog.push();

Expand Down
5 changes: 4 additions & 1 deletion js/listeners/PressListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,10 @@ export default class PressListener extends EnabledComponent implements TInputLis
sceneryLog && sceneryLog.InputListener && sceneryLog.InputListener( `PressListener#${this._id} drag` );
sceneryLog && sceneryLog.InputListener && sceneryLog.push();

assert && assert( this.isPressed, 'Can only drag while pressed' );
// If we got interrupted while events were queued up, we MAY get a drag when not pressed. We can ignore this.
if ( !this.isPressed ) {
return;
}

this._dragListener( event, this );

Expand Down

0 comments on commit ec4a0e1

Please sign in to comment.