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

Is there a way to toggle draggable status without unmout/mount element #756

Closed
2 tasks
qi-min opened this issue Mar 15, 2018 · 3 comments
Closed
2 tasks

Comments

@qi-min
Copy link

qi-min commented Mar 15, 2018

Thanks for submitting an issue to RGL!

Please mark the type of this issue:

  • Bug
  • Feature Request
  • [ √] Question

If you have a question or bug report, please use the WebpackBin Template
to demonstrate. It is much easier for us to help you if you do.

I need a function to toggle draggable status. I do this by changing 'static' or 'isDraggable' property in layout. But changing these two properties will lead element unmounted. Mount a new element take a while in my app because it require data from network. Is there any way to change the status without re-mount the element?

@luminaxster
Copy link

luminaxster commented Mar 17, 2018

TL;DR: Try providing your own draggableHandle=".className":

Example:

render(){
const {isDraggable} = this.props; // or state...
// more code
return <Responsive draggableHandle=".draggable" > 
  <div key="x" >
            <div className={isDraggable?'draggable': 'disabled'}>
              {/*... can be any component */}
           </div>
  </div>
{/*...*/}
</Responsive>;
}

As soon as you remove the 'draggable' className from the div, RGL will not find the handle, thus disabling dragging.

@qi-min
Copy link
Author

qi-min commented Mar 20, 2018

Thanks @luminaxster , this way does work.

@qi-min qi-min closed this as completed Mar 20, 2018
@trydzynski-zen
Copy link

I'm impacted by this as well. When I toggle isDraggable and isResizable, all widgets are recreated.
My widgets (the draggable component) cache their queries, so remounting them does not cause network load, however they blink and/or animate which looks poorly.

Could this be fixed in the library, e.g. by calling functions, instead of adding Resizable/Draggable mixins via wrapping in new components? That should be enough to unlock react's reuse of components (I have verified the cause, but not the fix).

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

3 participants