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

Disable dnd #473

Closed
maxcc0 opened this issue Jun 15, 2016 · 5 comments
Closed

Disable dnd #473

maxcc0 opened this issue Jun 15, 2016 · 5 comments

Comments

@maxcc0
Copy link

maxcc0 commented Jun 15, 2016

Is there a hook with which dnd can be disabled? I'm trying to reuse a dnd component and want to disable dnd.

@froatsnook
Copy link
Collaborator

I'm not sure I understand your question. Do you want to prevent a component from being dragged in some cases? If so, you could implement this by giving your component a prop canDrag.

// drag source spec
{
  ...
  canDrag: function(props, monitor) {
    return props.canDrag;
  },
  ...
}

Then you can either render your component with canDrag={true} or canDrag={false}.

  <MyComponent canDrag={true} />
  <MyComponent canDrag={false} />

Let me know if you meant something else.

@kesne
Copy link
Collaborator

kesne commented Aug 20, 2016

Hey @maxcc0, it looks like your issue has been resolved with the above sample (which is what I was going to recommend before I saw it had already been posted!). Feel free to open a new issue or comment here if you have more questions!

@kesne kesne closed this as completed Aug 20, 2016
@donszek
Copy link

donszek commented May 1, 2017

@froatsnook @kesne
Hello, can I check, where should I implement the canDrag function? I am using a custom drag layer similar to the source here.

Thank you.

@sethmcleod
Copy link

@donszek Assuming your code is similar to the example you linked to, you would add the canDrag function here, in the spec function (is this case, boxSource) for your DragSource.

@s875515
Copy link

s875515 commented May 27, 2019

I'm not sure I understand your question. Do you want to prevent a component from being dragged in some cases? If so, you could implement this by giving your component a prop canDrag.

// drag source spec
{
  ...
  canDrag: function(props, monitor) {
    return props.canDrag;
  },
  ...
}

Then you can either render your component with canDrag={true} or canDrag={false}.

  <MyComponent canDrag={true} />
  <MyComponent canDrag={false} />

Let me know if you meant something else.

it will be calling canDrop now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants