jQuery droppable - receiving events during drag over (not just on initial drag over)

前端 未结 5 1794
忘掉有多难
忘掉有多难 2021-01-31 09:50

I am using jQuery droppable (in conjunction with jQuery draggable) to allow the user to add rows to an HTML table by dragging items from a list and dropping them on the table.

5条回答
  •  抹茶落季
    2021-01-31 10:42

    I am hitting the same issue and have been thinking about two solutions which I will share in case they give direction to others who find this relatively rare need.

    • Two div solution: Add two divs into each cell of the row, positioned to be stacked and each 50% high and full width with z-index set to -1 to protect from UI interference. Now make these droppables and use their 'over' and 'out' events to toggle the classes of the parent cell or row.

    • Abandon droppable and roll your own collision detection: Write your own collision detection to mimic the droppable effect. This which would give more freedom but would lead to some serious coding and so is not for the casual requirement. Would also be susceptible to performance issues. That said, there should be some obvious case-based shortcuts that would work in your favour.

    I would be interested to hear of any other approaches to low-code solution.

提交回复
热议问题