@@ -60,19 +60,29 @@ export interface SortableComponent {
60
60
canPut : ( detail : DragDetail ) => boolean ;
61
61
62
62
/**
63
- * Called by any change to the list (add / update / remove) .
63
+ * Called when any sortable component drag starts. For internal use only. Any public drag events should emit within `onDragStart()` .
64
64
*/
65
- onDragSort : ( detail : DragDetail ) => void ;
65
+ onGlobalDragStart : ( ) => void ;
66
+
67
+ /**
68
+ * Called when any sortable component drag ends. For internal use only. Any public drag events should emit within `onDragEnd()`.
69
+ */
70
+ onGlobalDragEnd : ( ) => void ;
66
71
67
72
/**
68
- * Called when a sortable component drag starts .
73
+ * Called when a component's dragging ends .
69
74
*/
70
- onDragStart : ( ) => void ;
75
+ onDragEnd : ( detail : DragDetail ) => void ;
71
76
72
77
/**
73
- * Called when a sortable component drag ends .
78
+ * Called when a component's dragging starts .
74
79
*/
75
- onDragEnd : ( ) => void ;
80
+ onDragStart : ( detail : DragDetail ) => void ;
81
+
82
+ /**
83
+ * Called by any change to the list (add / update / remove).
84
+ */
85
+ onDragSort : ( detail : DragDetail ) => void ;
76
86
}
77
87
78
88
export interface SortableComponentItem {
@@ -119,13 +129,15 @@ export function connectSortableComponent(component: SortableComponent): void {
119
129
} ) ,
120
130
handle,
121
131
filter : "[drag-disabled]" ,
122
- onStart : ( ) => {
132
+ onStart : ( { from : fromEl , item : dragEl , to : toEl , newIndex , oldIndex } ) => {
123
133
dragState . active = true ;
124
- onDragStart ( ) ;
134
+ onGlobalDragStart ( ) ;
135
+ component . onDragStart ( { fromEl, dragEl, toEl, newIndex, oldIndex } ) ;
125
136
} ,
126
- onEnd : ( ) => {
137
+ onEnd : ( { from : fromEl , item : dragEl , to : toEl , newIndex , oldIndex } ) => {
127
138
dragState . active = false ;
128
- onDragEnd ( ) ;
139
+ onGlobalDragEnd ( ) ;
140
+ component . onDragEnd ( { fromEl, dragEl, toEl, newIndex, oldIndex } ) ;
129
141
} ,
130
142
onSort : ( { from : fromEl , item : dragEl , to : toEl , newIndex, oldIndex } ) => {
131
143
component . onDragSort ( { fromEl, dragEl, toEl, newIndex, oldIndex } ) ;
@@ -157,10 +169,10 @@ export function dragActive(component: SortableComponent): boolean {
157
169
return component . dragEnabled && dragState . active ;
158
170
}
159
171
160
- function onDragStart ( ) : void {
161
- Array . from ( sortableComponentSet ) . forEach ( ( component ) => component . onDragStart ( ) ) ;
172
+ function onGlobalDragStart ( ) : void {
173
+ Array . from ( sortableComponentSet ) . forEach ( ( component ) => component . onGlobalDragStart ( ) ) ;
162
174
}
163
175
164
- function onDragEnd ( ) : void {
165
- Array . from ( sortableComponentSet ) . forEach ( ( component ) => component . onDragEnd ( ) ) ;
176
+ function onGlobalDragEnd ( ) : void {
177
+ Array . from ( sortableComponentSet ) . forEach ( ( component ) => component . onGlobalDragEnd ( ) ) ;
166
178
}
0 commit comments