react-resizable
react-resizable copied to clipboard
[issue] draggableOpts callbacks get overwritten
- [x] Issue
Goal: I want to have an element that is resizable and draggable. How: by using react-resizable and passing callbacks to draggableOpts such that:
<ResizableBox className="box" width={200} height={200} draggableOpts={{
grid: [25, 25],
onStart: function() {console.log('drag start')},
onDrag: function() {console.log('drag')},
onStop: function() {console.log('drag stop')}
}}>
<span className="text">test</span>
</ResizableBox>
Problem: Draggable opts callbacks are not called. Why? In lib/resizable.js we have:
<DraggableCore
{...draggableOpts}
key="resizableHandle"
onStop={this.resizeHandler('onResizeStop')}
onStart={this.resizeHandler('onResizeStart')}
onDrag={this.resizeHandler('onResize')}
>
<span className="react-resizable-handle" />
</DraggableCore>
which after spreading looks like:
<DraggableCore
grid: [25, 25],
onStop={I will be over written}
onStart={I will be over written}
onDrag={I will be over written}
key="resizableHandle"
onStop={this.resizeHandler('onResizeStop')}
onStart={this.resizeHandler('onResizeStart')}
onDrag={this.resizeHandler('onResize')}
>
<span className="react-resizable-handle" />
</DraggableCore>
Please confirm that this is an issue indeed.
Hi @kutyepov. I am facing the same issue. Have you got it working ?.