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

[issue] draggableOpts callbacks get overwritten

Open kutyepov opened this issue 8 years ago • 1 comments

  • [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.

kutyepov avatar Dec 25 '17 06:12 kutyepov

Hi @kutyepov. I am facing the same issue. Have you got it working ?.

devnidhinraj avatar Apr 11 '18 17:04 devnidhinraj