@os-design/drag-sort 1.0.1 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/DragAndDrop.js +7 -1
- package/dist/cjs/DragAndDrop.js.map +1 -1
- package/dist/cjs/Draggable.js.map +1 -1
- package/dist/cjs/Droppable.js +4 -8
- package/dist/cjs/Droppable.js.map +1 -1
- package/dist/cjs/utils/ListStore.js +1 -1
- package/dist/cjs/utils/ListStore.js.map +1 -1
- package/dist/cjs/utils/useBlankNode.js.map +1 -1
- package/dist/cjs/utils/useDragEffect.js +146 -129
- package/dist/cjs/utils/useDragEffect.js.map +1 -1
- package/dist/cjs/utils/useInitRect.js.map +1 -1
- package/dist/cjs/utils/useInitScrollOffset.js.map +1 -1
- package/dist/cjs/utils/useMoveNode.js +25 -19
- package/dist/cjs/utils/useMoveNode.js.map +1 -1
- package/dist/esm/DragAndDrop.js +6 -1
- package/dist/esm/DragAndDrop.js.map +1 -1
- package/dist/esm/Draggable.js.map +1 -1
- package/dist/esm/Droppable.js +4 -8
- package/dist/esm/Droppable.js.map +1 -1
- package/dist/esm/utils/ListStore.js +1 -1
- package/dist/esm/utils/ListStore.js.map +1 -1
- package/dist/esm/utils/useBlankNode.js.map +1 -1
- package/dist/esm/utils/useDragEffect.js +125 -107
- package/dist/esm/utils/useDragEffect.js.map +1 -1
- package/dist/esm/utils/useInitRect.js.map +1 -1
- package/dist/esm/utils/useInitScrollOffset.js.map +1 -1
- package/dist/esm/utils/useMoveNode.js +60 -47
- package/dist/esm/utils/useMoveNode.js.map +1 -1
- package/dist/types/DragAndDrop.d.ts.map +1 -1
- package/dist/types/Draggable.d.ts +1 -1
- package/dist/types/Draggable.d.ts.map +1 -1
- package/dist/types/Droppable.d.ts +1 -1
- package/dist/types/Droppable.d.ts.map +1 -1
- package/dist/types/utils/useBlankNode.d.ts +3 -1
- package/dist/types/utils/useBlankNode.d.ts.map +1 -1
- package/dist/types/utils/useDragEffect.d.ts.map +1 -1
- package/dist/types/utils/useInitRect.d.ts.map +1 -1
- package/dist/types/utils/useInitScrollOffset.d.ts.map +1 -1
- package/dist/types/utils/useMoveNode.d.ts +12 -5
- package/dist/types/utils/useMoveNode.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -5,11 +5,9 @@ import getElementScroll from './getElementScroll';
|
|
|
5
5
|
import useTargetList from './useTargetList';
|
|
6
6
|
import useInitRect from './useInitRect';
|
|
7
7
|
import useInitScrollOffset from './useInitScrollOffset';
|
|
8
|
-
import useGetNodeStyle from './useGetNodeStyle';
|
|
9
|
-
|
|
8
|
+
import useGetNodeStyle from './useGetNodeStyle';
|
|
10
9
|
import useMoveNode from './useMoveNode';
|
|
11
|
-
import getNodeRect from './getNodeRect';
|
|
12
|
-
|
|
10
|
+
import getNodeRect from './getNodeRect';
|
|
13
11
|
import useBlankNode from './useBlankNode';
|
|
14
12
|
const HIDDEN_NODE_STYLE = {
|
|
15
13
|
opacity: 0,
|
|
@@ -22,7 +20,7 @@ const createEmptyNode = ({
|
|
|
22
20
|
}) => [prev, next, {
|
|
23
21
|
current: null
|
|
24
22
|
}, () => {}, -1];
|
|
25
|
-
/* eslint-disable
|
|
23
|
+
/* eslint-disable no-constant-condition */
|
|
26
24
|
|
|
27
25
|
|
|
28
26
|
const useDragEffect = props => {
|
|
@@ -44,8 +42,7 @@ const useDragEffect = props => {
|
|
|
44
42
|
// We can't read the bounds of the dragged node on the fly because the node can be unmounted in the virtual list.
|
|
45
43
|
|
|
46
44
|
const initDraggedNodeRect = useInitRect(draggedNode ? draggedNode.node[2] : undefined); // The initial scroll position of the list where the dragged node is located.
|
|
47
|
-
// Used to detect the actual position of the dragged node.
|
|
48
|
-
// The purpose is the same as with initDraggedNodeRect.
|
|
45
|
+
// Used to detect the actual position of the dragged node. The purpose is the same as with initDraggedNodeRect.
|
|
49
46
|
|
|
50
47
|
const initDraggedNodeListScrollOffset = useInitScrollOffset(draggedNode ? draggedNode.list.ref : undefined); // The central position of the dragged node
|
|
51
48
|
|
|
@@ -63,12 +60,17 @@ const useDragEffect = props => {
|
|
|
63
60
|
x: x - draggedNode.position.x + initWidth / 2,
|
|
64
61
|
y: y - draggedNode.position.y + initHeight / 2
|
|
65
62
|
};
|
|
66
|
-
}, [cursorPosition, draggedNode, initDraggedNodeRect]); //
|
|
63
|
+
}, [cursorPosition, draggedNode, initDraggedNodeRect]); // The list in which the cursor is located
|
|
67
64
|
|
|
68
|
-
const
|
|
65
|
+
const targetList = useTargetList(position, listStoreRef); // Returns the style for moving the node in the specified direction
|
|
69
66
|
|
|
70
|
-
const
|
|
71
|
-
|
|
67
|
+
const getNodeStyle = useGetNodeStyle(initDraggedNodeRect); // Moves the node up or down
|
|
68
|
+
|
|
69
|
+
const moveNode = useMoveNode({
|
|
70
|
+
position,
|
|
71
|
+
draggedNode,
|
|
72
|
+
getNodeStyle
|
|
73
|
+
});
|
|
72
74
|
const setTargetNode = useCallback((list, node) => {
|
|
73
75
|
const [,,,, nodeIndex] = node;
|
|
74
76
|
targetNodeRef.current = {
|
|
@@ -130,14 +132,14 @@ const useDragEffect = props => {
|
|
|
130
132
|
const updateTargetNode = useCallback(() => {
|
|
131
133
|
if (!draggedNode) return;
|
|
132
134
|
const prevTargetNode = targetNodeRef.current; // The last updated node
|
|
133
|
-
// Dragging outside the list
|
|
135
|
+
// Dragging outside the origin list
|
|
134
136
|
|
|
135
137
|
if (prevTargetNode && prevTargetNode.list === draggedNode.list && targetList !== draggedNode.list) {
|
|
136
138
|
moveNode({
|
|
137
139
|
list: prevTargetNode.list,
|
|
138
140
|
startNode: prevTargetNode.node,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
direction: 'down',
|
|
142
|
+
destination: 'end'
|
|
141
143
|
});
|
|
142
144
|
clearTargetNode();
|
|
143
145
|
} // Dragging outside another list
|
|
@@ -147,13 +149,13 @@ const useDragEffect = props => {
|
|
|
147
149
|
moveNode({
|
|
148
150
|
list: prevTargetNode.list,
|
|
149
151
|
startNode: prevTargetNode.node,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
direction: 'down',
|
|
153
|
+
destination: 'end',
|
|
154
|
+
isAnotherList: true
|
|
153
155
|
});
|
|
154
156
|
removeBlankNode();
|
|
155
157
|
clearTargetNode();
|
|
156
|
-
} // Dragging inside the list
|
|
158
|
+
} // Dragging inside the origin list
|
|
157
159
|
|
|
158
160
|
|
|
159
161
|
if (!prevTargetNode && targetList === draggedNode.list) {
|
|
@@ -162,7 +164,8 @@ const useDragEffect = props => {
|
|
|
162
164
|
const node = moveNode({
|
|
163
165
|
list: targetList,
|
|
164
166
|
startNode: tail,
|
|
165
|
-
|
|
167
|
+
direction: 'up',
|
|
168
|
+
destination: 'cursor'
|
|
166
169
|
});
|
|
167
170
|
setTargetNode(targetList, node);
|
|
168
171
|
return;
|
|
@@ -175,12 +178,13 @@ const useDragEffect = props => {
|
|
|
175
178
|
const node = moveNode({
|
|
176
179
|
list: targetList,
|
|
177
180
|
startNode: tail,
|
|
178
|
-
|
|
179
|
-
|
|
181
|
+
direction: 'up',
|
|
182
|
+
destination: 'cursor',
|
|
183
|
+
isAnotherList: true
|
|
180
184
|
});
|
|
181
185
|
setTargetNode(targetList, node);
|
|
182
186
|
return;
|
|
183
|
-
} // Dragging in the
|
|
187
|
+
} // Dragging in the origin list
|
|
184
188
|
|
|
185
189
|
|
|
186
190
|
if (prevTargetNode && prevTargetNode.list === draggedNode.list && targetList === draggedNode.list) {
|
|
@@ -204,7 +208,8 @@ const useDragEffect = props => {
|
|
|
204
208
|
startNode: createEmptyNode({
|
|
205
209
|
prev: tail
|
|
206
210
|
}),
|
|
207
|
-
|
|
211
|
+
direction: 'up',
|
|
212
|
+
destination: 'cursor'
|
|
208
213
|
});
|
|
209
214
|
setTargetNode(targetList, node);
|
|
210
215
|
} else {
|
|
@@ -215,7 +220,8 @@ const useDragEffect = props => {
|
|
|
215
220
|
startNode: createEmptyNode({
|
|
216
221
|
next: head
|
|
217
222
|
}),
|
|
218
|
-
|
|
223
|
+
direction: 'down',
|
|
224
|
+
destination: 'cursor'
|
|
219
225
|
});
|
|
220
226
|
setTargetNode(targetList, node);
|
|
221
227
|
}
|
|
@@ -224,17 +230,19 @@ const useDragEffect = props => {
|
|
|
224
230
|
}
|
|
225
231
|
|
|
226
232
|
const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);
|
|
227
|
-
const
|
|
233
|
+
const startRectProp = targetList.horizontal ? 'left' : 'top';
|
|
228
234
|
if (!position || !prevTargetNodeRect) return;
|
|
229
|
-
const isMoveUp = position[axis] < prevTargetNodeRect[
|
|
235
|
+
const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];
|
|
230
236
|
const node = isMoveUp ? moveNode({
|
|
231
237
|
list: targetList,
|
|
232
238
|
startNode: prevTargetNode.node,
|
|
233
|
-
|
|
239
|
+
direction: 'up',
|
|
240
|
+
destination: 'cursor'
|
|
234
241
|
}) : moveNode({
|
|
235
242
|
list: targetList,
|
|
236
243
|
startNode: prevTargetNode.node,
|
|
237
|
-
|
|
244
|
+
direction: 'down',
|
|
245
|
+
destination: 'cursor'
|
|
238
246
|
});
|
|
239
247
|
setTargetNode(targetList, node);
|
|
240
248
|
return;
|
|
@@ -244,19 +252,21 @@ const useDragEffect = props => {
|
|
|
244
252
|
if (targetList && targetList !== draggedNode.list && prevTargetNode && prevTargetNode.list === targetList) {
|
|
245
253
|
const axis = targetList.horizontal ? 'x' : 'y';
|
|
246
254
|
const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);
|
|
247
|
-
const
|
|
255
|
+
const startRectProp = targetList.horizontal ? 'left' : 'top';
|
|
248
256
|
if (!position || !prevTargetNodeRect) return;
|
|
249
|
-
const isMoveUp = position[axis] < prevTargetNodeRect[
|
|
257
|
+
const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];
|
|
250
258
|
const node = isMoveUp ? moveNode({
|
|
251
259
|
list: targetList,
|
|
252
260
|
startNode: prevTargetNode.node,
|
|
253
|
-
|
|
254
|
-
|
|
261
|
+
direction: 'up',
|
|
262
|
+
destination: 'cursor',
|
|
263
|
+
isAnotherList: true
|
|
255
264
|
}) : moveNode({
|
|
256
265
|
list: targetList,
|
|
257
266
|
startNode: prevTargetNode.node,
|
|
258
|
-
|
|
259
|
-
|
|
267
|
+
direction: 'down',
|
|
268
|
+
destination: 'cursor',
|
|
269
|
+
isAnotherList: true
|
|
260
270
|
});
|
|
261
271
|
setTargetNode(targetList, node);
|
|
262
272
|
}
|
|
@@ -268,77 +278,81 @@ const useDragEffect = props => {
|
|
|
268
278
|
|
|
269
279
|
const [throttledUpdateTargetNode] = useThrottle(updateTargetNode, 100);
|
|
270
280
|
useEvent(targetList ? targetList.ref : undefined, 'scroll', throttledUpdateTargetNode);
|
|
271
|
-
useEvent(window, 'scroll', throttledUpdateTargetNode); // Reset styles of the nodes when the dragged node was dropped
|
|
281
|
+
useEvent(window, 'scroll', throttledUpdateTargetNode); // Reset styles of the affected nodes when the dragged node was dropped
|
|
272
282
|
|
|
273
283
|
useEffect(() => {
|
|
274
284
|
if (!draggedNode) return () => {};
|
|
275
285
|
const [,,,, draggedNodeIndex] = draggedNode.node;
|
|
276
286
|
return () => {
|
|
277
|
-
const targetNode = targetNodeRef.current; // If the dragged node was
|
|
278
|
-
// starting at the tail and ending with the dragged node.
|
|
279
|
-
|
|
280
|
-
if (targetNode && targetNode.list !== draggedNode.list) {
|
|
281
|
-
const tail = targetNode.list.getTail();
|
|
282
|
-
if (!tail) return;
|
|
283
|
-
let node = tail;
|
|
284
|
-
|
|
285
|
-
while (true) {
|
|
286
|
-
const [prev,,, nodeSetStyle, nodeIndex] = node;
|
|
287
|
-
nodeSetStyle({});
|
|
288
|
-
if (!prev || nodeIndex <= draggedNodeIndex) break;
|
|
289
|
-
node = prev;
|
|
290
|
-
}
|
|
291
|
-
} // If the dragged node was outside the origin list, reset the styles for the nodes,
|
|
292
|
-
// starting at the tail and ending with the dragged node.
|
|
293
|
-
|
|
287
|
+
const targetNode = targetNodeRef.current; // If the dragged node was outside the origin list, reset the styles for the nodes,
|
|
288
|
+
// starting at the tail and ending with the dragged node in the origin list.
|
|
294
289
|
|
|
295
|
-
|
|
290
|
+
if (!targetNode || targetNode.list !== draggedNode.list) {
|
|
291
|
+
const tail = draggedNode.list.getTail();
|
|
296
292
|
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
if (tail) {
|
|
294
|
+
let node = tail;
|
|
299
295
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
while (true) {
|
|
297
|
+
const [prev,,, nodeSetStyle, nodeIndex] = node;
|
|
298
|
+
nodeSetStyle({});
|
|
299
|
+
if (!prev || nodeIndex <= draggedNodeIndex) break;
|
|
300
|
+
node = prev;
|
|
301
|
+
}
|
|
305
302
|
}
|
|
306
|
-
}
|
|
303
|
+
} // If the dragged node was inside another list, reset the styles for the nodes,
|
|
304
|
+
// starting at the tail and ending with the dragged node in the target list.
|
|
307
305
|
|
|
308
|
-
if (!targetNode) return;
|
|
309
|
-
const [,,, targetNodeSetStyle, targetNodeIndex] = targetNode.node;
|
|
310
|
-
|
|
311
|
-
if (targetNodeIndex > draggedNodeIndex) {
|
|
312
|
-
let {
|
|
313
|
-
node
|
|
314
|
-
} = targetNode;
|
|
315
|
-
|
|
316
|
-
while (true) {
|
|
317
|
-
const [prev,,, nodeSetStyle, nodeIndex] = node;
|
|
318
|
-
nodeSetStyle({});
|
|
319
|
-
if (!prev || nodeIndex < draggedNodeIndex) return;
|
|
320
|
-
node = prev;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
306
|
|
|
324
|
-
if (
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
} = targetNode;
|
|
307
|
+
if (targetNode && targetNode.list !== draggedNode.list) {
|
|
308
|
+
const tail = targetNode.list.getTail();
|
|
309
|
+
const [,,,, targetNodeIndex] = targetNode.node;
|
|
328
310
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
nodeSetStyle({});
|
|
332
|
-
if (!next || nodeIndex > draggedNodeIndex) return;
|
|
333
|
-
node = next;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
311
|
+
if (tail) {
|
|
312
|
+
let node = tail;
|
|
336
313
|
|
|
337
|
-
|
|
338
|
-
|
|
314
|
+
while (true) {
|
|
315
|
+
const [prev,,, nodeSetStyle, nodeIndex] = node;
|
|
316
|
+
nodeSetStyle({});
|
|
317
|
+
if (!prev || nodeIndex <= targetNodeIndex) break;
|
|
318
|
+
node = prev;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} // If the dragged node was moved inside the origin list, reset the styles for the nodes,
|
|
322
|
+
// starting with target node and ending with the dragged node.
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
if (targetNode && targetNode.list === draggedNode.list) {
|
|
326
|
+
const [,,, targetNodeSetStyle, targetNodeIndex] = targetNode.node;
|
|
327
|
+
|
|
328
|
+
if (targetNodeIndex > draggedNodeIndex) {
|
|
329
|
+
let {
|
|
330
|
+
node
|
|
331
|
+
} = targetNode;
|
|
332
|
+
|
|
333
|
+
while (true) {
|
|
334
|
+
const [prev,,, nodeSetStyle, nodeIndex] = node;
|
|
335
|
+
nodeSetStyle({});
|
|
336
|
+
if (!prev || nodeIndex <= draggedNodeIndex) break;
|
|
337
|
+
node = prev;
|
|
338
|
+
}
|
|
339
|
+
} else if (targetNodeIndex < draggedNodeIndex) {
|
|
340
|
+
let {
|
|
341
|
+
node
|
|
342
|
+
} = targetNode;
|
|
343
|
+
|
|
344
|
+
while (true) {
|
|
345
|
+
const [, next,, nodeSetStyle, nodeIndex] = node;
|
|
346
|
+
nodeSetStyle({});
|
|
347
|
+
if (!next || nodeIndex >= draggedNodeIndex) break;
|
|
348
|
+
node = next;
|
|
349
|
+
}
|
|
350
|
+
} else if (targetNodeIndex === draggedNodeIndex) {
|
|
351
|
+
targetNodeSetStyle({});
|
|
352
|
+
}
|
|
339
353
|
}
|
|
340
354
|
};
|
|
341
|
-
}, [draggedNode]); // Update the position of the mounted nodes
|
|
355
|
+
}, [draggedNode]); // Update the position of the newly mounted nodes in the origin list (used in the virtual list)
|
|
342
356
|
|
|
343
357
|
useEffect(() => {
|
|
344
358
|
if (!draggedNode) return () => {};
|
|
@@ -349,32 +363,33 @@ const useDragEffect = props => {
|
|
|
349
363
|
setStyle,
|
|
350
364
|
index
|
|
351
365
|
} = nodeProps;
|
|
352
|
-
const targetNode = targetNodeRef.current; //
|
|
353
|
-
|
|
354
|
-
if ((!targetNodeRef.current || targetNodeRef.current.list !== draggedNode.list) && index > draggedNodeIndex) {
|
|
355
|
-
setStyle(getNodeStyle('up', draggedNode.list.horizontal));
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (!targetNode || !targetNode.node) return;
|
|
360
|
-
const [,,,, targetNodeIndex] = targetNode.node; // If the dragged node was mounted
|
|
366
|
+
const targetNode = targetNodeRef.current; // Set the hidden style, if the mounted node is the dragged node
|
|
361
367
|
|
|
362
368
|
if (index === draggedNodeIndex) {
|
|
363
369
|
setStyle(HIDDEN_NODE_STYLE);
|
|
364
370
|
return;
|
|
365
|
-
} // If the node
|
|
371
|
+
} // If the dragged node is inside the origin list
|
|
372
|
+
|
|
366
373
|
|
|
374
|
+
if (targetNode && targetNode.list === draggedNode.list) {
|
|
375
|
+
// Move the mounted node up/down, if it is located between the dragged and target node
|
|
376
|
+
const [,,,, targetNodeIndex] = targetNode.node;
|
|
367
377
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
378
|
+
if (index > draggedNodeIndex && index < targetNodeIndex) {
|
|
379
|
+
setStyle(getNodeStyle('up', targetNode.list.horizontal));
|
|
380
|
+
} else if (index < draggedNodeIndex && index > targetNodeIndex) {
|
|
381
|
+
setStyle(getNodeStyle('down', targetNode.list.horizontal));
|
|
382
|
+
}
|
|
383
|
+
} else if (index > draggedNodeIndex) {
|
|
384
|
+
// Otherwise, move the mounted node up, if it is located below the dragged node
|
|
385
|
+
setStyle(getNodeStyle('up', draggedNode.list.horizontal));
|
|
372
386
|
}
|
|
373
387
|
};
|
|
374
388
|
|
|
375
389
|
draggedNode.list.addListener(update);
|
|
376
390
|
return () => draggedNode.list.removeListener(update);
|
|
377
|
-
}, [draggedNode, getNodeStyle]);
|
|
391
|
+
}, [draggedNode, getNodeStyle]); // Update the position of the newly mounted nodes in the target list (used in the virtual list)
|
|
392
|
+
|
|
378
393
|
useEffect(() => {
|
|
379
394
|
if (!draggedNode || !targetList || targetList === draggedNode.list) {
|
|
380
395
|
return () => {};
|
|
@@ -388,8 +403,11 @@ const useDragEffect = props => {
|
|
|
388
403
|
const targetNode = targetNodeRef.current;
|
|
389
404
|
if (!targetNode) return;
|
|
390
405
|
const [,,,, targetNodeIndex] = targetNode.node;
|
|
391
|
-
|
|
392
|
-
|
|
406
|
+
|
|
407
|
+
if (index >= targetNodeIndex) {
|
|
408
|
+
// Move the mounted node down, if it is located below the target node or if it is the target node
|
|
409
|
+
setStyle(getNodeStyle('down', targetList.horizontal));
|
|
410
|
+
}
|
|
393
411
|
};
|
|
394
412
|
|
|
395
413
|
targetList.addListener(update);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/useDragEffect.ts"],"names":["useCallback","useEffect","useMemo","useRef","useThrottle","useEvent","getElementScroll","useTargetList","useInitRect","useInitScrollOffset","useGetNodeStyle","useMoveNode","getNodeRect","useBlankNode","HIDDEN_NODE_STYLE","opacity","pointerEvents","createEmptyNode","prev","next","current","useDragEffect","props","draggedNode","cursorPosition","listStoreRef","onDragEnd","targetRef","targetNodeRef","onDragEndRef","initDraggedNodeRect","node","undefined","initDraggedNodeListScrollOffset","list","ref","position","x","y","initWidth","initHeight","getNodeStyle","targetList","moveNode","setTargetNode","nodeIndex","id","index","clearTargetNode","getDraggedNodePos","initX","initY","initScrollLeft","initScrollTop","scrollLeft","scrollTop","getDraggedNodePosRef","draggedNodeSetStyle","removeBlankNode","updateTargetNode","prevTargetNode","startNode","type","untilTheEnd","insideAnotherList","tail","getTail","axis","horizontal","prevTargetNodeRef","draggedNodePos","isDraggingUp","head","getHead","prevTargetNodeRect","rectProp","isMoveUp","throttledUpdateTargetNode","window","draggedNodeIndex","targetNode","nodeSetStyle","targetNodeSetStyle","targetNodeIndex","update","nodeProps","setStyle","addListener","removeListener","target","dragged"],"mappings":"AACA,SAGEA,WAHF,EAIEC,SAJF,EAKEC,OALF,EAMEC,MANF,QAOO,OAPP;AAQA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAGA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,mBAAP,MAAgC,uBAAhC;AACA,OAAOC,eAAP,MAA4B,mBAA5B,C,CACA;;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,eAAxB,C,CACA;;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AA8BA,MAAMC,iBAAgC,GAAG;AACvCC,EAAAA,OAAO,EAAE,CAD8B;AAEvCC,EAAAA,aAAa,EAAE;AAFwB,CAAzC;;AAKA,MAAMC,eAAe,GAAG,CAAC;AACvBC,EAAAA,IAAI,GAAG,IADgB;AAEvBC,EAAAA,IAAI,GAAG;AAFgB,CAAD,KAMJ,CAACD,IAAD,EAAOC,IAAP,EAAa;AAAEC,EAAAA,OAAO,EAAE;AAAX,CAAb,EAAgC,MAAM,CAAE,CAAxC,EAA0C,CAAC,CAA3C,CANpB;AAQA;;;AAEA,MAAMC,aAAa,GAAIC,KAAD,IAA+B;AACnD,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,cAAf;AAA+BC,IAAAA,YAA/B;AAA6CC,IAAAA;AAA7C,MAA2DJ,KAAjE;AAEA,QAAMK,SAAS,GAAGxB,MAAM,CAAsB,I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2C,MAAM,CAAC3C,EAAtB,IAA4B4C,OAAO,CAAC3C,KAAR,KAAkB0C,MAAM,CAAC1C,KAAzD,EAAgE;AAChElB,MAAAA,YAAY,CAACT,OAAb,CAAqBsE,OAArB,EAA8BD,MAA9B;AACD,KARD;AASD,GAXQ,EAWN,CAAClE,WAAD,CAXM,CAAT;AAYD,CA7YD;;AA+YA,eAAeF,aAAf","sourcesContent":["import { Position } from '@os-design/use-drag';\nimport {\n CSSProperties,\n RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport useThrottle from '@os-design/use-throttle';\nimport useEvent from '@os-design/use-event';\nimport NodeList, { ExistingNode, Node, NodeProps } from './NodeList';\nimport ListStore from './ListStore';\nimport getElementScroll from './getElementScroll';\nimport useTargetList from './useTargetList';\nimport useInitRect from './useInitRect';\nimport useInitScrollOffset from './useInitScrollOffset';\nimport useGetNodeStyle from './useGetNodeStyle';\n// eslint-disable-next-line import/no-cycle\nimport useMoveNode from './useMoveNode';\nimport getNodeRect from './getNodeRect';\n// eslint-disable-next-line import/no-cycle\nimport useBlankNode from './useBlankNode';\n\nexport interface DraggedNode {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ninterface TargetNode {\n list: NodeList;\n node: ExistingNode;\n}\n\nexport interface ItemLocation {\n id: string;\n index: number;\n}\n\nexport type DragEndHandler = (\n dragged: ItemLocation,\n target: ItemLocation\n) => void;\n\ninterface UseDragEffectProps {\n draggedNode: DraggedNode | null;\n cursorPosition: Position;\n listStoreRef: RefObject<ListStore>;\n onDragEnd: DragEndHandler;\n}\n\nconst HIDDEN_NODE_STYLE: CSSProperties = {\n opacity: 0,\n pointerEvents: 'none',\n};\n\nconst createEmptyNode = ({\n prev = null,\n next = null,\n}: {\n prev?: Node;\n next?: Node;\n}): ExistingNode => [prev, next, { current: null }, () => {}, -1];\n\n/* eslint-disable @typescript-eslint/no-explicit-any,no-constant-condition */\n\nconst useDragEffect = (props: UseDragEffectProps) => {\n const { draggedNode, cursorPosition, listStoreRef, onDragEnd } = props;\n\n const targetRef = useRef<ItemLocation | null>(null);\n const targetNodeRef = useRef<TargetNode | null>(draggedNode);\n\n useEffect(() => {\n targetNodeRef.current = draggedNode;\n }, [draggedNode]);\n\n const onDragEndRef = useRef(onDragEnd);\n useEffect(() => {\n onDragEndRef.current = onDragEnd;\n }, [onDragEnd]);\n\n // The initial bounds of the dragged node.\n // We can't read the bounds of the dragged node on the fly because the node can be unmounted in the virtual list.\n const initDraggedNodeRect = useInitRect(\n draggedNode ? draggedNode.node[2] : undefined\n );\n\n // The initial scroll position of the list where the dragged node is located.\n // Used to detect the actual position of the dragged node.\n // The purpose is the same as with initDraggedNodeRect.\n const initDraggedNodeListScrollOffset = useInitScrollOffset(\n draggedNode ? draggedNode.list.ref : undefined\n );\n\n // The central position of the dragged node\n const position = useMemo(() => {\n if (!draggedNode || !initDraggedNodeRect) return null;\n const { x, y } = cursorPosition;\n const { initWidth, initHeight } = initDraggedNodeRect;\n return {\n x: x - draggedNode.position.x + initWidth / 2,\n y: y - draggedNode.position.y + initHeight / 2,\n };\n }, [cursorPosition, draggedNode, initDraggedNodeRect]);\n\n // Returns the style for moving the node in the specified direction\n const getNodeStyle = useGetNodeStyle(initDraggedNodeRect);\n\n // The list in which the cursor is located\n const targetList = useTargetList(position, listStoreRef);\n\n const moveNode = useMoveNode(position, draggedNode, getNodeStyle);\n\n const setTargetNode = useCallback((list: NodeList, node: ExistingNode) => {\n const [, , , , nodeIndex] = node;\n targetNodeRef.current = { list, node };\n targetRef.current = { id: list.id, index: nodeIndex };\n }, []);\n\n const clearTargetNode = useCallback(() => {\n targetNodeRef.current = null;\n targetRef.current = null;\n }, []);\n\n // Returns the central position of the dragged node in the list\n const getDraggedNodePos = useCallback(() => {\n if (\n !targetList ||\n !targetList.ref.current ||\n !initDraggedNodeRect ||\n !initDraggedNodeListScrollOffset\n ) {\n return null;\n }\n const { initX, initY, initWidth, initHeight } = initDraggedNodeRect;\n const { initScrollLeft, initScrollTop } = initDraggedNodeListScrollOffset;\n const { scrollLeft, scrollTop } = getElementScroll(targetList.ref.current);\n return {\n x: initX + initWidth / 2 + initScrollLeft - scrollLeft,\n y: initY + initHeight / 2 + initScrollTop - scrollTop,\n };\n }, [initDraggedNodeListScrollOffset, initDraggedNodeRect, targetList]);\n\n const getDraggedNodePosRef = useRef(getDraggedNodePos);\n useEffect(() => {\n getDraggedNodePosRef.current = getDraggedNodePos;\n }, [getDraggedNodePos]);\n\n // Hide the dragged node\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , draggedNodeSetStyle] = draggedNode.node;\n draggedNodeSetStyle(HIDDEN_NODE_STYLE);\n return () => draggedNodeSetStyle({});\n }, [draggedNode]);\n\n // Append the blank node to the list to increase the height of it.\n // Used when the dragged node is located inside another list.\n const removeBlankNode = useBlankNode({\n draggedNode,\n targetList,\n initDraggedNodeRect,\n });\n\n const updateTargetNode = useCallback(() => {\n if (!draggedNode) return;\n const prevTargetNode = targetNodeRef.current; // The last updated node\n\n // Dragging outside the list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList !== draggedNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n type: 'down',\n untilTheEnd: true,\n });\n clearTargetNode();\n }\n\n // Dragging outside another list\n if (\n prevTargetNode &&\n prevTargetNode.list !== draggedNode.list &&\n targetList !== prevTargetNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n type: 'down',\n untilTheEnd: true,\n insideAnotherList: true,\n });\n removeBlankNode();\n clearTargetNode();\n }\n\n // Dragging inside the list\n if (!prevTargetNode && targetList === draggedNode.list) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n type: 'up',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging inside another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n (!prevTargetNode || prevTargetNode.list !== targetList)\n ) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n type: 'up',\n insideAnotherList: true,\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in the same list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList === draggedNode.list\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const [, , prevTargetNodeRef, ,] = prevTargetNode.node;\n if (!prevTargetNodeRef.current) {\n // The target node was unmounted. It happens when the virtual list is used.\n // If the cursor is above the dragged node, we need to move the nodes down from the tail to the node where\n // the cursor is located. Otherwise, we need to move the nodes up from the head to the node where the cursor\n // is located.\n const draggedNodePos = getDraggedNodePosRef.current();\n if (!position || !draggedNodePos) return;\n const isDraggingUp = position[axis] < draggedNodePos[axis];\n if (isDraggingUp) {\n const tail = targetList.getTail();\n if (!tail || !tail[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ prev: tail }),\n type: 'up',\n });\n setTargetNode(targetList, node);\n } else {\n const head = targetList.getHead();\n if (!head || !head[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ next: head }),\n type: 'down',\n });\n setTargetNode(targetList, node);\n }\n return;\n }\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const rectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[rectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n type: 'up',\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n type: 'down',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n prevTargetNode &&\n prevTargetNode.list === targetList\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const rectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[rectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n type: 'up',\n insideAnotherList: true,\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n type: 'down',\n insideAnotherList: true,\n });\n setTargetNode(targetList, node);\n }\n }, [\n draggedNode,\n targetList,\n moveNode,\n clearTargetNode,\n removeBlankNode,\n setTargetNode,\n position,\n ]);\n\n // Update the target node if either the position or the target list has been changed\n useEffect(() => {\n updateTargetNode();\n }, [updateTargetNode]);\n\n // Update the target node if the target list has been scrolled\n const [throttledUpdateTargetNode] = useThrottle(updateTargetNode, 100);\n useEvent(\n (targetList ? targetList.ref : undefined) as any,\n 'scroll',\n throttledUpdateTargetNode\n );\n useEvent(window, 'scroll', throttledUpdateTargetNode);\n\n // Reset styles of the nodes when the dragged node was dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n return () => {\n const targetNode = targetNodeRef.current;\n\n // If the dragged node was inside another list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node.\n if (targetNode && targetNode.list !== draggedNode.list) {\n const tail = targetNode.list.getTail();\n if (!tail) return;\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n }\n\n // If the dragged node was outside the origin list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node.\n const tail = draggedNode.list.getTail();\n if ((!targetNode || targetNode.list !== draggedNode.list) && tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n }\n\n if (!targetNode) return;\n const [, , , targetNodeSetStyle, targetNodeIndex] = targetNode.node;\n if (targetNodeIndex > draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex < draggedNodeIndex) return;\n node = prev;\n }\n }\n if (targetNodeIndex < draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!next || nodeIndex > draggedNodeIndex) return;\n node = next;\n }\n }\n if (targetNodeIndex === draggedNodeIndex) {\n targetNodeSetStyle({});\n }\n };\n }, [draggedNode]);\n\n // Update the position of the mounted nodes between the dragged and target nodes (used in virtual list)\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n\n // If the dragged node outside the origin list\n if (\n (!targetNodeRef.current ||\n targetNodeRef.current.list !== draggedNode.list) &&\n index > draggedNodeIndex\n ) {\n setStyle(getNodeStyle('up', draggedNode.list.horizontal));\n return;\n }\n\n if (!targetNode || !targetNode.node) return;\n const [, , , , targetNodeIndex] = targetNode.node;\n // If the dragged node was mounted\n if (index === draggedNodeIndex) {\n setStyle(HIDDEN_NODE_STYLE);\n return;\n }\n // If the node between the dragged and target nodes was mounted\n if (index > draggedNodeIndex && index < targetNodeIndex) {\n setStyle(getNodeStyle('up', targetNode.list.horizontal));\n } else if (index < draggedNodeIndex && index > targetNodeIndex) {\n setStyle(getNodeStyle('down', targetNode.list.horizontal));\n }\n };\n draggedNode.list.addListener(update);\n return () => draggedNode.list.removeListener(update);\n }, [draggedNode, getNodeStyle]);\n\n useEffect(() => {\n if (!draggedNode || !targetList || targetList === draggedNode.list) {\n return () => {};\n }\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n if (!targetNode) return;\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index < targetNodeIndex) return;\n setStyle(getNodeStyle('down', targetList.horizontal));\n };\n targetList.addListener(update);\n return () => targetList.removeListener(update);\n }, [draggedNode, getNodeStyle, targetList]);\n\n // Call the onDragEnd callback if the draggedNode was changed to null\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const target = targetRef.current;\n if (!target) return;\n const [, , , , draggedNodeIndex] = draggedNode.node;\n const dragged = { id: draggedNode.list.id, index: draggedNodeIndex };\n if (dragged.id === target.id && dragged.index === target.index) return;\n onDragEndRef.current(dragged, target);\n };\n }, [draggedNode]);\n};\n\nexport default useDragEffect;\n"],"file":"useDragEffect.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/useDragEffect.ts"],"names":["useCallback","useEffect","useMemo","useRef","useThrottle","useEvent","getElementScroll","useTargetList","useInitRect","useInitScrollOffset","useGetNodeStyle","useMoveNode","getNodeRect","useBlankNode","HIDDEN_NODE_STYLE","opacity","pointerEvents","createEmptyNode","prev","next","current","useDragEffect","props","draggedNode","cursorPosition","listStoreRef","onDragEnd","targetRef","targetNodeRef","onDragEndRef","initDraggedNodeRect","node","undefined","initDraggedNodeListScrollOffset","list","ref","position","x","y","initWidth","initHeight","targetList","getNodeStyle","moveNode","setTargetNode","nodeIndex","id","index","clearTargetNode","getDraggedNodePos","initX","initY","initScrollLeft","initScrollTop","scrollLeft","scrollTop","getDraggedNodePosRef","draggedNodeSetStyle","removeBlankNode","updateTargetNode","prevTargetNode","startNode","direction","destination","isAnotherList","tail","getTail","axis","horizontal","prevTargetNodeRef","draggedNodePos","isDraggingUp","head","getHead","prevTargetNodeRect","startRectProp","isMoveUp","throttledUpdateTargetNode","window","draggedNodeIndex","targetNode","nodeSetStyle","targetNodeIndex","targetNodeSetStyle","update","nodeProps","setStyle","addListener","removeListener","target","dragged"],"mappings":"AACA,SAGEA,WAHF,EAIEC,SAJF,EAKEC,OALF,EAMEC,MANF,QAOO,OAPP;AAQA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,QAAP,MAAqB,sBAArB;A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B4C,OAAO,CAAC3C,KAAR,KAAkB0C,MAAM,CAAC1C,KAAzD,EAAgE;AAChElB,MAAAA,YAAY,CAACT,OAAb,CAAqBsE,OAArB,EAA8BD,MAA9B;AACD,KARD;AASD,GAXQ,EAWN,CAAClE,WAAD,CAXM,CAAT;AAYD,CA7ZD;;AA+ZA,eAAeF,aAAf","sourcesContent":["import { Position } from '@os-design/use-drag';\nimport {\n CSSProperties,\n RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport useThrottle from '@os-design/use-throttle';\nimport useEvent from '@os-design/use-event';\nimport NodeList, { ExistingNode, Node, NodeProps } from './NodeList';\nimport ListStore from './ListStore';\nimport getElementScroll from './getElementScroll';\nimport useTargetList from './useTargetList';\nimport useInitRect from './useInitRect';\nimport useInitScrollOffset from './useInitScrollOffset';\nimport useGetNodeStyle from './useGetNodeStyle';\nimport useMoveNode from './useMoveNode';\nimport getNodeRect from './getNodeRect';\nimport useBlankNode from './useBlankNode';\n\nexport interface DraggedNode {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ninterface TargetNode {\n list: NodeList;\n node: ExistingNode;\n}\n\nexport interface ItemLocation {\n id: string;\n index: number;\n}\n\nexport type DragEndHandler = (\n dragged: ItemLocation,\n target: ItemLocation\n) => void;\n\ninterface UseDragEffectProps {\n draggedNode: DraggedNode | null;\n cursorPosition: Position;\n listStoreRef: RefObject<ListStore>;\n onDragEnd: DragEndHandler;\n}\n\nconst HIDDEN_NODE_STYLE: CSSProperties = {\n opacity: 0,\n pointerEvents: 'none',\n};\n\nconst createEmptyNode = ({\n prev = null,\n next = null,\n}: {\n prev?: Node;\n next?: Node;\n}): ExistingNode => [prev, next, { current: null }, () => {}, -1];\n\n/* eslint-disable no-constant-condition */\n\nconst useDragEffect = (props: UseDragEffectProps) => {\n const { draggedNode, cursorPosition, listStoreRef, onDragEnd } = props;\n\n const targetRef = useRef<ItemLocation | null>(null);\n const targetNodeRef = useRef<TargetNode | null>(draggedNode);\n\n useEffect(() => {\n targetNodeRef.current = draggedNode;\n }, [draggedNode]);\n\n const onDragEndRef = useRef(onDragEnd);\n useEffect(() => {\n onDragEndRef.current = onDragEnd;\n }, [onDragEnd]);\n\n // The initial bounds of the dragged node.\n // We can't read the bounds of the dragged node on the fly because the node can be unmounted in the virtual list.\n const initDraggedNodeRect = useInitRect(\n draggedNode ? draggedNode.node[2] : undefined\n );\n\n // The initial scroll position of the list where the dragged node is located.\n // Used to detect the actual position of the dragged node. The purpose is the same as with initDraggedNodeRect.\n const initDraggedNodeListScrollOffset = useInitScrollOffset(\n draggedNode ? draggedNode.list.ref : undefined\n );\n\n // The central position of the dragged node\n const position = useMemo(() => {\n if (!draggedNode || !initDraggedNodeRect) return null;\n const { x, y } = cursorPosition;\n const { initWidth, initHeight } = initDraggedNodeRect;\n return {\n x: x - draggedNode.position.x + initWidth / 2,\n y: y - draggedNode.position.y + initHeight / 2,\n };\n }, [cursorPosition, draggedNode, initDraggedNodeRect]);\n\n // The list in which the cursor is located\n const targetList = useTargetList(position, listStoreRef);\n\n // Returns the style for moving the node in the specified direction\n const getNodeStyle = useGetNodeStyle(initDraggedNodeRect);\n\n // Moves the node up or down\n const moveNode = useMoveNode({ position, draggedNode, getNodeStyle });\n\n const setTargetNode = useCallback((list: NodeList, node: ExistingNode) => {\n const [, , , , nodeIndex] = node;\n targetNodeRef.current = { list, node };\n targetRef.current = { id: list.id, index: nodeIndex };\n }, []);\n\n const clearTargetNode = useCallback(() => {\n targetNodeRef.current = null;\n targetRef.current = null;\n }, []);\n\n // Returns the central position of the dragged node in the list\n const getDraggedNodePos = useCallback(() => {\n if (\n !targetList ||\n !targetList.ref.current ||\n !initDraggedNodeRect ||\n !initDraggedNodeListScrollOffset\n ) {\n return null;\n }\n const { initX, initY, initWidth, initHeight } = initDraggedNodeRect;\n const { initScrollLeft, initScrollTop } = initDraggedNodeListScrollOffset;\n const { scrollLeft, scrollTop } = getElementScroll(targetList.ref.current);\n return {\n x: initX + initWidth / 2 + initScrollLeft - scrollLeft,\n y: initY + initHeight / 2 + initScrollTop - scrollTop,\n };\n }, [initDraggedNodeListScrollOffset, initDraggedNodeRect, targetList]);\n\n const getDraggedNodePosRef = useRef(getDraggedNodePos);\n useEffect(() => {\n getDraggedNodePosRef.current = getDraggedNodePos;\n }, [getDraggedNodePos]);\n\n // Hide the dragged node\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , draggedNodeSetStyle] = draggedNode.node;\n draggedNodeSetStyle(HIDDEN_NODE_STYLE);\n return () => draggedNodeSetStyle({});\n }, [draggedNode]);\n\n // Append the blank node to the list to increase the height of it.\n // Used when the dragged node is located inside another list.\n const removeBlankNode = useBlankNode({\n draggedNode,\n targetList,\n initDraggedNodeRect,\n });\n\n const updateTargetNode = useCallback(() => {\n if (!draggedNode) return;\n const prevTargetNode = targetNodeRef.current; // The last updated node\n\n // Dragging outside the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList !== draggedNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n });\n clearTargetNode();\n }\n\n // Dragging outside another list\n if (\n prevTargetNode &&\n prevTargetNode.list !== draggedNode.list &&\n targetList !== prevTargetNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n isAnotherList: true,\n });\n removeBlankNode();\n clearTargetNode();\n }\n\n // Dragging inside the origin list\n if (!prevTargetNode && targetList === draggedNode.list) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging inside another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n (!prevTargetNode || prevTargetNode.list !== targetList)\n ) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList === draggedNode.list\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const [, , prevTargetNodeRef, ,] = prevTargetNode.node;\n if (!prevTargetNodeRef.current) {\n // The target node was unmounted. It happens when the virtual list is used.\n // If the cursor is above the dragged node, we need to move the nodes down from the tail to the node where\n // the cursor is located. Otherwise, we need to move the nodes up from the head to the node where the cursor\n // is located.\n const draggedNodePos = getDraggedNodePosRef.current();\n if (!position || !draggedNodePos) return;\n const isDraggingUp = position[axis] < draggedNodePos[axis];\n if (isDraggingUp) {\n const tail = targetList.getTail();\n if (!tail || !tail[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ prev: tail }),\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n } else {\n const head = targetList.getHead();\n if (!head || !head[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ next: head }),\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n }\n return;\n }\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n prevTargetNode &&\n prevTargetNode.list === targetList\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n }\n }, [\n draggedNode,\n targetList,\n moveNode,\n clearTargetNode,\n removeBlankNode,\n setTargetNode,\n position,\n ]);\n\n // Update the target node if either the position or the target list has been changed\n useEffect(() => {\n updateTargetNode();\n }, [updateTargetNode]);\n\n // Update the target node if the target list has been scrolled\n const [throttledUpdateTargetNode] = useThrottle(updateTargetNode, 100);\n useEvent(\n (targetList ? targetList.ref : undefined) as unknown as EventTarget,\n 'scroll',\n throttledUpdateTargetNode\n );\n useEvent(window, 'scroll', throttledUpdateTargetNode);\n\n // Reset styles of the affected nodes when the dragged node was dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n return () => {\n const targetNode = targetNodeRef.current;\n\n // If the dragged node was outside the origin list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the origin list.\n if (!targetNode || targetNode.list !== draggedNode.list) {\n const tail = draggedNode.list.getTail();\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was inside another list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the target list.\n if (targetNode && targetNode.list !== draggedNode.list) {\n const tail = targetNode.list.getTail();\n const [, , , , targetNodeIndex] = targetNode.node;\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= targetNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was moved inside the origin list, reset the styles for the nodes,\n // starting with target node and ending with the dragged node.\n if (targetNode && targetNode.list === draggedNode.list) {\n const [, , , targetNodeSetStyle, targetNodeIndex] = targetNode.node;\n if (targetNodeIndex > draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n } else if (targetNodeIndex < draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!next || nodeIndex >= draggedNodeIndex) break;\n node = next;\n }\n } else if (targetNodeIndex === draggedNodeIndex) {\n targetNodeSetStyle({});\n }\n }\n };\n }, [draggedNode]);\n\n // Update the position of the newly mounted nodes in the origin list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n\n // Set the hidden style, if the mounted node is the dragged node\n if (index === draggedNodeIndex) {\n setStyle(HIDDEN_NODE_STYLE);\n return;\n }\n\n // If the dragged node is inside the origin list\n if (targetNode && targetNode.list === draggedNode.list) {\n // Move the mounted node up/down, if it is located between the dragged and target node\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index > draggedNodeIndex && index < targetNodeIndex) {\n setStyle(getNodeStyle('up', targetNode.list.horizontal));\n } else if (index < draggedNodeIndex && index > targetNodeIndex) {\n setStyle(getNodeStyle('down', targetNode.list.horizontal));\n }\n } else if (index > draggedNodeIndex) {\n // Otherwise, move the mounted node up, if it is located below the dragged node\n setStyle(getNodeStyle('up', draggedNode.list.horizontal));\n }\n };\n\n draggedNode.list.addListener(update);\n return () => draggedNode.list.removeListener(update);\n }, [draggedNode, getNodeStyle]);\n\n // Update the position of the newly mounted nodes in the target list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode || !targetList || targetList === draggedNode.list) {\n return () => {};\n }\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n if (!targetNode) return;\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index >= targetNodeIndex) {\n // Move the mounted node down, if it is located below the target node or if it is the target node\n setStyle(getNodeStyle('down', targetList.horizontal));\n }\n };\n\n targetList.addListener(update);\n return () => targetList.removeListener(update);\n }, [draggedNode, getNodeStyle, targetList]);\n\n // Call the onDragEnd callback if the draggedNode was changed to null\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const target = targetRef.current;\n if (!target) return;\n const [, , , , draggedNodeIndex] = draggedNode.node;\n const dragged = { id: draggedNode.list.id, index: draggedNodeIndex };\n if (dragged.id === target.id && dragged.index === target.index) return;\n onDragEndRef.current(dragged, target);\n };\n }, [draggedNode]);\n};\n\nexport default useDragEffect;\n"],"file":"useDragEffect.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/useInitRect.ts"],"names":["useMemo","useInitRect","ref","current","rect","getBoundingClientRect","initX","x","initY","y","initWidth","width","initHeight","height"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;;AAEA,MAAMC,WAAW,GAAIC,GAAD,IAClBF,OAAO,CAAC,MAAM;AACZ,MAAI,CAACE,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/useInitRect.ts"],"names":["useMemo","useInitRect","ref","current","rect","getBoundingClientRect","initX","x","initY","y","initWidth","width","initHeight","height"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;;AAEA,MAAMC,WAAW,GAAIC,GAAD,IAClBF,OAAO,CAAC,MAAM;AACZ,MAAI,CAACE,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;AAE1B,QAAMC,IAAI,GAAGF,GAAG,CAACC,OAAJ,CAAYE,qBAAZ,EAAb;AAEA,SAAO;AACLC,IAAAA,KAAK,EAAEF,IAAI,CAACG,CADP;AAELC,IAAAA,KAAK,EAAEJ,IAAI,CAACK,CAFP;AAGLC,IAAAA,SAAS,EAAEN,IAAI,CAACO,KAHX;AAILC,IAAAA,UAAU,EAAER,IAAI,CAACS;AAJZ,GAAP;AAMD,CAXM,EAWJ,CAACX,GAAD,CAXI,CADT;;AAcA,eAAeD,WAAf","sourcesContent":["import { RefObject, useMemo } from 'react';\n\nconst useInitRect = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const rect = ref.current.getBoundingClientRect();\n\n return {\n initX: rect.x,\n initY: rect.y,\n initWidth: rect.width,\n initHeight: rect.height,\n };\n }, [ref]);\n\nexport default useInitRect;\n"],"file":"useInitRect.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/useInitScrollOffset.ts"],"names":["useMemo","getElementScroll","useInitScrollOffset","ref","current","scrollOffset","initScrollLeft","scrollLeft","initScrollTop","scrollTop"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAEA,MAAMC,mBAAmB,GAAIC,GAAD,IAC1BH,OAAO,CAAC,MAAM;AACZ,MAAI,CAACG,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/useInitScrollOffset.ts"],"names":["useMemo","getElementScroll","useInitScrollOffset","ref","current","scrollOffset","initScrollLeft","scrollLeft","initScrollTop","scrollTop"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAEA,MAAMC,mBAAmB,GAAIC,GAAD,IAC1BH,OAAO,CAAC,MAAM;AACZ,MAAI,CAACG,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;AAE1B,QAAMC,YAAY,GAAGJ,gBAAgB,CAACE,GAAG,CAACC,OAAL,CAArC;AAEA,SAAO;AACLE,IAAAA,cAAc,EAAED,YAAY,CAACE,UADxB;AAELC,IAAAA,aAAa,EAAEH,YAAY,CAACI;AAFvB,GAAP;AAID,CATM,EASJ,CAACN,GAAD,CATI,CADT;;AAYA,eAAeD,mBAAf","sourcesContent":["import { RefObject, useMemo } from 'react';\nimport getElementScroll from './getElementScroll';\n\nconst useInitScrollOffset = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const scrollOffset = getElementScroll(ref.current);\n\n return {\n initScrollLeft: scrollOffset.scrollLeft,\n initScrollTop: scrollOffset.scrollTop,\n };\n }, [ref]);\n\nexport default useInitScrollOffset;\n"],"file":"useInitScrollOffset.js"}
|