在第二个拖动中拖动项目时出现奇怪的行为react-beautiful-dnd [英] Strange behavior when dragging items on the second drag react-beautiful-dnd

查看:62
本文介绍了在第二个拖动中拖动项目时出现奇怪的行为react-beautiful-dnd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,在使用react-beautiful-dnd软件包时,每秒拖曳的效果都不佳(见图)

For some reason every second drag is not performing very well when using the react-beautiful-dnd package (see image)

我的onDragEnd函数看起来像这样:

my onDragEnd function is looking like this:

  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

Having getNodes that is returning child components

不确定该行为的负责人..有什么想法吗?

Not sure what the responsible is for this behaviour.. any ideas?

推荐答案

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

Keep in mind that 11.0 is still in beta! It is not recommended for production yet. If you face any issues, please use the stable 10.x release.

我们感谢您遇到有关 11.0 的任何问题的详细信息,因此我们可以解决这些问题.提交问题

We appreciate details on any issues you are facing with 11.0 so we can address them. Submit an issue

这篇关于在第二个拖动中拖动项目时出现奇怪的行为react-beautiful-dnd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆