Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

需要在两个GridLayout之间移动GridItem,请问有什么解决办法? #19

Open
touchrank-dev opened this issue Mar 16, 2024 · 2 comments

Comments

@touchrank-dev
Copy link

尝试过在GridItem移动事件中,删除源GridLayout中的layout数组中的item,再插入到目标GridLayout的layout数组中,但这样会引发handleDrag中的异常:

  if (!mouseInGrid) {
    let draggingIndex = layoutData.value[0].findIndex(ele => ele.i === itemId)
    let removed = layoutData.value[0].splice(draggingIndex, 1)
    console.log(layoutData.value[0], removed)
  }

大概可以模仿drag-from-outside例子,但先要解决拖少源GridItem时从源数组上删除该项引发异常?

@touchrank-dev
Copy link
Author

By studying the 'drag, drop from outside' example, I tried to implement this feature but failed. At first, the GridItem's move event doesn't expose the clientX and clientY of MouseEvent, so I cannot check whether the item is moved out or not. Second is, GridItem's move and moved events sometimes are not emitted, so I cannot call grid's dragEvent() accordingly. After that, removing a record from layout array during dragging will throw exception ( in hadleDray function of GridItem) because the HtmlElement is removed synchronously.
About the behavior of dragging and dropping an item between grids even crossing some grids, I think I should remove the placeholder from source grid when the item dragged is moved out, and append and move a placeholder in the dragging over grid ( and also remove it when mouse out), when the mouse is released in target grid, insert the item. If the mouse is released out of any grids, the source grid will be restored and the removed item will show in its original position.

Perhaps this feature is not a high priority, but I need this and am eager to find how to implement it. Hope I can hear from you. Thank you very much.

@touchrank-dev
Copy link
Author

谢谢。我已经做了一些尝试,基本实现拖放功能,但仍有些错误。我再试试你提供的例子。希工作顺利

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant