Javascript 我应该使用坐标来处理Draggably的dropzone吗

Javascript 我应该使用坐标来处理Draggably的dropzone吗,javascript,coffeescript,draggable,droppable,Javascript,Coffeescript,Draggable,Droppable,我正在一个项目中使用,以使某些元素可拖动。要知道元素何时在dropzone中,我使用drag事件中的指针 它给了我这样的东西: # I store boudings and element in an array cards_bounding = [] matches = document.querySelectorAll("#board .card"); for match in matches bounding = match.getBoundingClientRect() card

我正在一个项目中使用,以使某些元素可拖动。要知道元素何时在dropzone中,我使用drag事件中的指针

它给了我这样的东西:

# I store boudings and element in an array
cards_bounding = []
matches = document.querySelectorAll("#board .card");
for match in matches
  bounding = match.getBoundingClientRect()
  cards_bounding.push(
    el: match
    bounding: 
      left: bounding.left
      right: bounding.right
      top: bounding.top
      bottom: bounding.bottom
  )

pointer_in_bounding = (pointer, bounding) ->
  bounding.left < pointer.pageX < bounding.right and bounding.top < pointer.pageY < bounding.bottom

# Then I check where is my pointer during the dragMove
drag_picked_card.on "dragMove", (draggieInstance, event, pointer) ->
  for card_bound in cards_bounding
    if pointer_in_bounding(pointer, card_bound.bounding)
      # …
#我在数组中存储束和元素
卡片\u边界=[]
匹配=document.queryselectoral(#board.card”);
一场接一场的比赛
bounding=match.getBoundingClientRect()
扑克牌(
艾尔:比赛
边界:
左:边界。左
右:边界。右
顶部:bounding.top
底部:bounding.bottom
)
指针\u在\u边界=(指针,边界)->
bounding.left
对于卡\u绑定在卡\u绑定中
如果指针在边界中(指针、卡片边界)
# …
这是实现这一目标的更好方法吗