1

由于某种原因,在使用 react-beautiful-dnd 包时,每秒钟的拖动效果都不是很好(见图)

在此处输入图像描述

我的 onDragEnd 函数如下所示:

  const onDragEnd = result => { 
    if (!result.destination) {
      return;
    }

    if (
      result.destination.droppableId === result.source.droppableId &&
      result.destination.index === result.source.index
    ) {
       return;
    }

    const draggedItem = list[result.source.index];
    list.splice(result.source.index, 1);
    list.splice(result.destination.index, 0, draggedItem);

    /** Firebase update */
    dbCon.once('value', function(snapshot) {
       snapshot.forEach(function(child) {
         list.map((listChild, index) => {
           if (listChild.props.draggableId === child.key) {
             child.ref.update({ position: index });
           }
         });
       });
     });

    setList(getNodes);
  };

拥有返回子组件的 getNodes

不确定这种行为的责任是什么..有什么想法吗?

4

2 回答 2

0

请记住,11.0仍然在beta!不建议用于生产。如果您遇到任何问题,请使用稳定10.x版本。

我们感谢您所面临的任何问题的详细信息,11.0以便我们解决这些问题。提交问题

于 2019-04-08T06:37:29.677 回答
0

当我使用 react-beautiful-dnd 版本 11.0.0-beta 时,我遇到了类似的问题。

Downgrading to 10.1.1 fixed the problem.

您可以找到与 11.0.0-beta 类似的问题,其中 isDragDisabled 在这里不起作用

于 2019-04-07T10:01:02.150 回答