Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ export function useDragDrop(options: UseDragDropOptions = {}) {
if (!isDragging) {
isDraggingRef.current = true
setIsDragging(true)
} else if (scrollAnimationRef.current === null) {
scrollAnimationRef.current = requestAnimationFrame(handleAutoScroll)
}

return true
},
[isDragging]
[isDragging, handleAutoScroll]
)

const getSiblingItems = useCallback(
Expand Down Expand Up @@ -616,6 +618,31 @@ export function useDragDrop(options: UseDragDropOptions = {}) {
siblingsCacheRef.current.clear()
}, [])

useEffect(() => {
if (!isDragging) return
const container = scrollContainerRef.current
if (!container) return
const onLeave = (e: DragEvent) => {
const related = e.relatedTarget as Node | null
if (related && container.contains(related)) return
if (scrollAnimationRef.current !== null) {
cancelAnimationFrame(scrollAnimationRef.current)
scrollAnimationRef.current = null
}
dropIndicatorRef.current = null
setDropIndicator(null)
setHoverFolderId(null)
}
container.addEventListener('dragleave', onLeave)
window.addEventListener('drop', handleDragEnd, true)
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
window.addEventListener('dragend', handleDragEnd, true)
return () => {
container.removeEventListener('dragleave', onLeave)
window.removeEventListener('drop', handleDragEnd, true)
window.removeEventListener('dragend', handleDragEnd, true)
}
}, [isDragging, handleDragEnd])
Comment thread
TheodoreSpeaks marked this conversation as resolved.
Comment thread
cursor[bot] marked this conversation as resolved.

const setScrollContainer = useCallback((element: HTMLDivElement | null) => {
scrollContainerRef.current = element
}, [])
Expand Down
Loading