Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectDragPreview() component is also displayed as regular component #780

Closed
croraf opened this issue May 28, 2017 · 3 comments
Closed
Labels

Comments

@croraf
Copy link

croraf commented May 28, 2017

Maybe this is possible duplicate of #399.
This is probably known behaviour, but would be good if following can be achieved:

render () {
        const { connectDragSource, connectDragPreview, isDragging } = this.props;

        return (
            <div className='top'>
                <div>Ordinary</div>
                {connectDragSource (<div>Dragabble</div>)}
                {connectDragPreview (<div>my preview</div>)}
            </div>
        );
}

I want my preview component to be shown only as an actual preview, not as an ordinary component.
But this shows <div>my preview</div> below the actual draggable component inside 'top' div. I don't want it to be shown there, but only as a preview. Can this be achieved?

@maierson
Copy link

maierson commented Jun 5, 2017

Here it is (use custom drag layer):
https://github.com/react-dnd/react-dnd/blob/master/examples/02%20Drag%20Around/Custom%20Drag%20Layer/CustomDragLayer.js

and this is the relevant part of the code:

import { getEmptyImage } from 'react-dnd-html5-backend';

componentDidMount() {
    // Use empty image as a drag preview so browsers don't draw it
    // and we can draw whatever we want on the custom drag layer instead.
    if (this.props.connectDragPreview) {
      this.props.connectDragPreview(getEmptyImage(), {
        // IE fallback: specify that we'd rather screenshot the node
        // when it already knows it's being dragged so we can hide it with CSS.
        captureDraggingState: true,
      });
    }
  }

@wiadev
Copy link

wiadev commented Apr 23, 2019

Hi
I need to build a custom dragPreview component beside dragSource component but when I use the above code in componentDidMount(), it shows no preview while dragging.

@stale
Copy link

stale bot commented Jul 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 6, 2019
@stale stale bot closed this as completed Jul 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants