-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move AllDragListenerOptions to its own file, see phetsims/scenery-phe…
- Loading branch information
1 parent
d8fcc25
commit b55eb9b
Showing
5 changed files
with
71 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
/** | ||
* Options used by many drag listeners in scenery. At this time, that includes DragListener and KeyboardDragListener. | ||
* | ||
* @author Jonathan Olson <[email protected]> | ||
* @author Michael Kauzmann (PhET Interactive Simulations) | ||
* @author Jesse Greenberg (PhET Interactive Simulations) | ||
*/ | ||
|
||
import Vector2 from '../../../dot/js/Vector2.js'; | ||
import { SceneryListenerCallback, SceneryListenerNullableCallback } from '../imports.js'; | ||
import TProperty from '../../../axon/js/TProperty.js'; | ||
import Transform3 from '../../../dot/js/Transform3.js'; | ||
import TReadOnlyProperty from '../../../axon/js/TReadOnlyProperty.js'; | ||
import Bounds2 from '../../../dot/js/Bounds2.js'; | ||
|
||
type MapPosition = ( point: Vector2 ) => Vector2; | ||
|
||
export type AllDragListenerOptions<Listener, DOMEvent extends Event> = { | ||
|
||
// Called when the drag is started. | ||
start?: SceneryListenerCallback<Listener, DOMEvent> | null; | ||
|
||
// Called when this listener is dragged. | ||
drag?: SceneryListenerCallback<Listener, DOMEvent> | null; | ||
|
||
// Called when the drag is ended. | ||
// NOTE: This will also be called if the drag is ended due to being interrupted or canceled. | ||
end?: SceneryListenerNullableCallback<Listener, DOMEvent> | null; | ||
|
||
// If provided, it will be synchronized with the drag position in the model coordinate frame. The optional transform | ||
// is applied. | ||
positionProperty?: Pick<TProperty<Vector2>, 'value'> | null; | ||
|
||
// If provided, this will be used to convert between the parent (view) and model coordinate frames. Most useful | ||
// when you also provide a positionProperty. | ||
transform?: Transform3 | TReadOnlyProperty<Transform3> | null; | ||
|
||
// If provided, the model position will be constrained to these bounds. | ||
dragBoundsProperty?: TReadOnlyProperty<Bounds2 | null> | null; | ||
|
||
// If provided, this allows custom mapping from the desired position (i.e. where the pointer is, or where the | ||
// KeyboardDragListener will set the position) to the actual position that will be used. | ||
mapPosition?: null | MapPosition; | ||
|
||
// If true, the target Node will be translated during the drag operation. | ||
translateNode?: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters