@@ -74,14 +74,16 @@ class DragAndDropController extends EventEmitter<DragAndDropEvents> {
7474 */
7575 public start ( transition : Transition ) {
7676 this . transition = { ...transition } ;
77- this . emit ( "start" , this . getDragAndDropData ( transition . startCoordinates ) ) ;
77+ this . emit ( "start" , this . getDragAndDropData ( transition , transition . startCoordinates ) ) ;
7878 }
7979
8080 /**
8181 * Updates current transition with given coordinates and issues an "update" event.
8282 */
8383 public update ( coordinates : Coordinates ) {
84- this . emit ( "update" , this . getDragAndDropData ( coordinates ) ) ;
84+ if ( this . transition ) {
85+ this . emit ( "update" , this . getDragAndDropData ( this . transition , coordinates ) ) ;
86+ }
8587 }
8688
8789 /**
@@ -104,10 +106,9 @@ class DragAndDropController extends EventEmitter<DragAndDropEvents> {
104106 * Issues an "acquire" event to notify the current transition draggable is acquired by the given droppable.
105107 */
106108 public acquire ( droppableId : ItemId , renderAcquiredItem : ( ) => ReactNode ) {
107- if ( ! this . transition ) {
108- throw new Error ( "Invariant violation: no transition present for acquire." ) ;
109+ if ( this . transition ) {
110+ this . emit ( "acquire" , { droppableId , draggableItem : this . transition . draggableItem , renderAcquiredItem } ) ;
109111 }
110- this . emit ( "acquire" , { droppableId, draggableItem : this . transition . draggableItem , renderAcquiredItem } ) ;
111112 }
112113
113114 /**
@@ -131,14 +132,11 @@ class DragAndDropController extends EventEmitter<DragAndDropEvents> {
131132 return [ ...this . droppables . entries ( ) ] ;
132133 }
133134
134- private getDragAndDropData ( coordinates : Coordinates ) : DragAndDropData {
135- if ( ! this . transition ) {
136- throw new Error ( "Invariant violation: no transition present for interaction." ) ;
137- }
138- const positionOffset = Coordinates . cursorOffset ( coordinates , this . transition . startCoordinates ) ;
139- const collisionRect = this . getCollisionRect ( this . transition , coordinates ) ;
135+ private getDragAndDropData ( transition : Transition , coordinates : Coordinates ) : DragAndDropData {
136+ const positionOffset = Coordinates . cursorOffset ( coordinates , transition . startCoordinates ) ;
137+ const collisionRect = this . getCollisionRect ( transition , coordinates ) ;
140138 const { collisionIds, dropTarget } = this . getCollisions ( collisionRect ) ;
141- return { ...this . transition , positionOffset, coordinates, collisionRect, collisionIds, dropTarget } ;
139+ return { ...transition , positionOffset, coordinates, collisionRect, collisionIds, dropTarget } ;
142140 }
143141
144142 private getCollisionRect ( transition : Transition , coordinates : Coordinates ) {
@@ -154,7 +152,6 @@ class DragAndDropController extends EventEmitter<DragAndDropEvents> {
154152 if ( collisionIds . length === 0 ) {
155153 return { collisionIds, dropTarget : null } ;
156154 }
157-
158155 const matchedDroppable = droppableEntries . find ( ( [ id ] ) => id === collisionIds [ 0 ] ) ;
159156 if ( ! matchedDroppable ) {
160157 throw new Error ( "Invariant violation: no droppable matches collision." ) ;
0 commit comments