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

How to tell when NOT hovering a drop target #359

Closed
cpsubrian opened this issue Jan 22, 2016 · 2 comments
Closed

How to tell when NOT hovering a drop target #359

cpsubrian opened this issue Jan 22, 2016 · 2 comments
Labels

Comments

@cpsubrian
Copy link

I'm trying to fire off redux actions that help track various DnD states globally. I need to know if dragging is happening and what type of target (ideally exactly which target) is being hovered. Detecting dragging is easy enough using the Source's spec, but I can't figure out how to detect hovering on a target. It has the 'hover' method in the spec, but that fires continuously, and as far as I can tell there isn't a way to tell when the hover stops. I could use timeouts but that seems less than ideal. I had thought to wrap the main app area in a dropTarget and use 'shallow' checking, but that doesn't give info about what type of drop target is being hovered. I suspect theres some way I could exploit the DnD Context but haven't dug in that far.

@cpsubrian
Copy link
Author

Might be able to bind my own onDrag* events to do what I need. Adds a slight interdependence between my app code and react-dnd, in terms of assumptions about which drag backend I'm using. But probably fine.

@gaearon
Copy link
Member

gaearon commented Feb 14, 2016

You can use componentWillReceiveProps lifecycle methods and fire an action when nextProps.isOver !== this.props.isOver. You’d need to add isOver: monitor.isOver() to your DropTarget’s collect() function.

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

2 participants