最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - react-beautiful-dnd draggable not visible during drag - Stack Overflow

programmeradmin3浏览0评论

I'm creating a trello-like ponent using react-beautiful-dnd however the draggable object isn't visible during a drag and I am struggling to figure out why.

See gif here

This is the relevant code: here

I feel as though it might have something to do with

<Draggable
  draggableId={this.props.task.id}
  index={this.props.index}
>
  {(provided, snapshot) =>
    <div className={this.getClassName(snapshot.isDragging)}
      {...provided.draggableProps}
      ref={provided.innerRef}
      onClick={this.toggleDialog}
    >
      //etc
    </div>
  )}
</Draggable>

But I'm stumped

I'm creating a trello-like ponent using react-beautiful-dnd however the draggable object isn't visible during a drag and I am struggling to figure out why.

See gif here

This is the relevant code: here

I feel as though it might have something to do with

<Draggable
  draggableId={this.props.task.id}
  index={this.props.index}
>
  {(provided, snapshot) =>
    <div className={this.getClassName(snapshot.isDragging)}
      {...provided.draggableProps}
      ref={provided.innerRef}
      onClick={this.toggleDialog}
    >
      //etc
    </div>
  )}
</Draggable>

But I'm stumped

Share Improve this question asked Nov 27, 2018 at 11:28 hqgoldhqgold 612 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

This usually happens when there is a transform property (Example transform: scale(0.9)) in the parent ponents.

So, the default position property fixed doesn't work as expected.

So, we either have to remove the transform property wrapping the drag and drop ponent or just override the position property with static.

<div className={this.getClassName(snapshot.isDragging)}
  {...provided.draggableProps}
  ref={provided.innerRef}
  style={{ ...provided.draggableProps.style, position: 'static' }}
  onClick={this.toggleDialog}
>
发布评论

评论列表(0)

  1. 暂无评论