diff --git a/README.md b/README.md index 75cb8c1..5277460 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,14 @@ Custom CSS classes can be specified for the resize handle and border: ``` +The enabled prop will toggle the drag on and off + +```js + +
left panel
+
+``` + ## Notes Tests on all modern browsers performed via BrowserStack. diff --git a/src/ResizePanel.js b/src/ResizePanel.js index 12f16ad..45a2f6b 100644 --- a/src/ResizePanel.js +++ b/src/ResizePanel.js @@ -76,7 +76,11 @@ class ResizePanel extends React.Component { } handleDrag = (e, ui) => { - const { direction } = this.props; + const { direction, enabled } = this.props; + if (!enabled) { + return; + } + const factor = direction === "e" || direction === "s" ? -1 : 1; // modify the size based on the drag delta @@ -85,6 +89,9 @@ class ResizePanel extends React.Component { }; handleDragEnd = (e, ui) => { + if (!this.props.enabled) { + return; + } this.validateSize(); };