簡體   English   中英

將元素拖動到其可滾動的父div之外-(React-Draggable)

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

React-Draggable ,我實現了拖放功能,其中必須將div (帶有圖像和一些元素)拖放到不同的類別中,但是當我們拖動元素時,它只能在父div內被拖動當我們嘗試將其拖出時,div會在div后面。

在此處輸入圖片說明

可拖動元素:

<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>

有沒有一種方法可以將元素在父div之外拖動到所需的目標位置,我正在使用帶有Typescript的React

注意:我仍然可以將元素放入其目標位置,但是唯一的事情是div落后了,而且看起來有點糟。

解決方法是,包含拖動元素的div滾動

overflow-y: scroll;

當拖動時,我將其刪除。之后,我可以將元素移動到div之外。 花了很多時間試圖將元素移出,並沒有考慮調整滾動條。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM