From 4780d0b9818eac354f568e54b1cf8c9c5229bfbc Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Mon, 19 Aug 2024 15:03:49 -0600 Subject: [PATCH] mapPosition and dragBoundsProperty are not mutually exclusive, https://github.com/phetsims/scenery/issues/1415 Signed-off-by: Michael Kauzmann --- js/listeners/DragListener.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/js/listeners/DragListener.ts b/js/listeners/DragListener.ts index 5f9715205..3a3ec11bf 100644 --- a/js/listeners/DragListener.ts +++ b/js/listeners/DragListener.ts @@ -224,11 +224,6 @@ export default class DragListener extends PressListener implements TInputListene assert && assert( !( options as unknown as { dragBounds: Bounds2 } ).dragBounds, 'options.dragBounds was removed in favor of options.dragBoundsProperty' ); assert && assert( !options.useParentOffset || options.positionProperty, 'If useParentOffset is set, a positionProperty is required' ); - assert && assert( - !( options.mapPosition && options.dragBoundsProperty ), - 'Only one of mapPosition and dragBoundsProperty can be provided, as they handle mapping of the drag point' - ); - // @ts-expect-error TODO: See https://github.com/phetsims/phet-core/issues/128 super( options ); @@ -598,9 +593,10 @@ export default class DragListener extends PressListener implements TInputListene */ protected mapModelPoint( modelPoint: Vector2 ): Vector2 { if ( this._mapPosition ) { - return this._mapPosition( modelPoint ); + modelPoint = this._mapPosition( modelPoint ); } - else if ( this._dragBoundsProperty.value ) { + + if ( this._dragBoundsProperty.value ) { return this._dragBoundsProperty.value.closestPointTo( modelPoint ); } else {