react-draggable icon indicating copy to clipboard operation
react-draggable copied to clipboard

How to save the position of react-draggable component after reloading(refreshing page)?

Open SudeshSharma opened this issue 7 years ago • 3 comments

I have created one form in which inputs elements drag according user needs. now i want to save the position of inputs fields and after refreshing the page i want to save the previous position of input fields(before refreshing) is it possible. if possible then how?

SudeshSharma avatar Jun 03 '19 05:06 SudeshSharma

I would save the current position when dragging stops (onStop) and then use it as a defaultPosition for next mount.

 defaultPosition={state.defaultPosition}
 onStop={(e, data) => {
          saveState({ defaultPosition: { x: data.x, y: data.y } });
        }}

Hope this helps.

Varad25 avatar Jul 05 '19 13:07 Varad25

@Varad25 solution worked great. Just saved default position for each element to the localstorage and it worked like a charm!

mdehaan51 avatar Sep 22 '19 20:09 mdehaan51

@Varad25 it doesn't work properly. It always mixup things.

oyesameed avatar Oct 06 '21 13:10 oyesameed