javascript - js drag and drop problem
巴扎黑
巴扎黑 2017-06-28 09:26:59
0
5
721

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?

巴扎黑
巴扎黑

reply all(5)
typecho

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

巴扎黑

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

迷茫

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.

黄舟

You can take a look at the drag event

drop(e) {
    e.target // 目标元素
}
大家讲道理

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template