【问题标题】:A bit complex drag and drop with react-beautiful-dndreact-beautiful-dnd 有点复杂的拖放
【发布时间】:2021-06-28 02:14:47
【问题描述】:

我正在使用react-beautiful-dnd 创建嵌套拖放。

在以下示例中,我可以在父母中对父母和孩子进行 DnD。

演示https://codesandbox.io/s/a-bit-complex-react-beautiful-dnd-tusln

我试图能够在列表之间(即在列表 1 中,从父 0 到父 1 或 2 以及从列表 2 到和从列表 2 中)对子项进行 DnD。

逻辑:

onDragEnd(result) {

    const { parents } = this.state;
    const { source, destination, type } = result;
    if (!destination) {
      return;
    }
    if (source.droppableId === destination.droppableId) {
      if (type === "PARENTS") {
        const _parents = reorder(parents, source.index, destination.index);
        this.setState({ parents: _parents });
      } else {
        const children = reorder(
          parents[parseInt(type, 10)].children,
          source.index,
          destination.index
        );

        const _parents = JSON.parse(JSON.stringify(parents));

        _parents[type].children = children;

        this.setState({ parents: _parents });
      }
    } else {
      const result = move(
        parents[parseInt(type, 10)].children,
        source,
        destination
      );

      this.setState({ parents: result.droppable });
    }
  }

我该如何处理?感谢您的宝贵时间。

【问题讨论】:

    标签: reactjs drag-and-drop react-beautiful-dnd


    【解决方案1】:
    猜你喜欢
    • 2019-03-19
    • 2020-05-05
    • 2020-08-04
    • 1970-01-01
    • 2021-02-08
    • 1970-01-01
    • 2020-12-04
    • 2020-09-02
    • 1970-01-01
    相关资源
    最近更新 更多