search

Home  >  Q&A  >  body text

javascript - js drag and drop problem

Drag a p to different areas, how to determine which area it is dragged to

Please select different option areas when dragging as shown. How to determine which area you have dragged to?

巴扎黑巴扎黑2701 days ago723

reply all(5)I'll reply

  • typecho

    typecho2017-06-28 09:28:59

    The drag API has little contact and only provides ideas: it can be judged based on the distance from the upper left corner of the target when it is dropped

    reply
    0
  • 巴扎黑

    巴扎黑2017-06-28 09:28:59

    Use positioning to judge the distance relative to the parent element. It is best to use a plug-in for dragging

    reply
    0
  • 迷茫

    迷茫2017-06-28 09:28:59

    Personal feeling can be judged by the top value of each p. For example, when the "Please select" block is moved, its top value is closest to the one below, and you can basically determine which area it has been dragged to.

    reply
    0
  • 黄舟

    黄舟2017-06-28 09:28:59

    You can take a look at the drag event

    drop(e) {
        e.target // 目标元素
    }

    reply
    0
  • 大家讲道理

    大家讲道理2017-06-28 09:28:59

    There are several events for dragging. Looking at the manual, there seem to be 7 events

    reply
    0
  • Cancelreply