简体   繁体   English

将元素拖动到其可滚动的父div之外-(React-Draggable)

[英]Drag an element outside its scrollable parent div - ( React-Draggable )

React-Draggable , I am implementing a drag-drop functionality in which a div ( with an image and some elements ) has to be dragged and dropped into different categories, but when we drag the element its able to be dragged only within the parent div and when we try to drag it out, div goes behind the div. React-Draggable ,我实现了拖放功能,其中必须将div (带有图像和一些元素)拖放到不同的类别中,但是当我们拖动元素时,它只能在父div内被拖动当我们尝试将其拖出时,div会在div后面。

在此处输入图片说明

Draggable element: 可拖动元素:

<Draggable
        position={{ x: 0, y: 0 }}
        onDrag={this.props.groupPageDragStartHandler}
        onStop={(event) => this.props.groupPageDragStopHandler(event, this.props.group, this.props.pageInfo)}
        defaultClassNameDragging="groupItemDragging"
        >
        <div className="group-report-items col-sm-4">
            <div className="canvas-outer">
                <input type="checkbox" className="checkbox" id={checkBoxId} value={checkBoxId} checked={this.state.selected} />
            <canvas
                    className="groupCanvas"
                    id={canvasId}
                    height="792"
                    width="612"
                    ref="imageCanvas"
                    onClick={(event) => this.selectHandler(event, this.props.group, this.props.pageInfo)}></canvas>
            <a canvas-id={canvasId} href="javascript:void(0)" className="search">
                <i className="glyphicon glyphicon-search">
                </i>
                </a>
                <a href="javascript:void(0)" className="trash">
                    <i className="glyphicon glyphicon-trash" onClick={(event) => this.props.onPageDeleteHandler(event, this.props.group, this.props.pageInfo)}>
                </i>
            </a>
        </div></div></Draggable>

Is there a way in which we could drag the element outside the parent div into its desired destination, I am using React with Typescript 有没有一种方法可以将元素在父div之外拖动到所需的目标位置,我正在使用带有Typescript的React

Note: I am able to still drop the element into its destination, but the only thing is the div goes behind and it looks kind of bad. 注意:我仍然可以将元素放入其目标位置,但是唯一的事情是div落后了,而且看起来有点糟。

The fix for this was, the div containing the drag elements had a scroll 解决方法是,包含拖动元素的div滚动

overflow-y: scroll;

when dragging I had the remove it.after which I was able to move the element outside the div. 当拖动时,我将其删除。之后,我可以将元素移动到div之外。 spent a lot of time trying to get the element out didn't think about tweaking the scroll. 花了很多时间试图将元素移出,并没有考虑调整滚动条。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM