DEV Community

Discussion on: How to get the distance of closest element while dragging over?

Collapse
 
aliplutus profile image
aliplutus • Edited

Solved

onDragOver={e => {
            e.preventDefault()
            const box = e.target.getBoundingClientRect()
            const offset = e.clientY - box.top - (box.height / 2)
            console.log(offset)

            setItems(pre => {
              return arrayMove(pre, eval(draged.id), index)
            })

          }}