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

Add stopPropagation call when resizing #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,18 @@ These props apply to both `<Resizable>` and `<ResizableBox>`.
draggableOpts?: ?Object
};
```

### Drag and resize

This library already implements [react-draggable](https://github.com/mzabriskie/react-draggable) for handling the resizing.
If you want to use a `react-resizable` box inside a `react-draggable` control, you should wrap the resizable control around a `div`:

```
<Draggable>
<div>
<ResizableBox>
<span>Resizable and draggable</span>
</ResizableBox>
</div>
</Draggable>
```
2 changes: 2 additions & 0 deletions lib/Resizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export default class Resizable extends React.Component<Props, State> {
} else {
this.setState(newState);
}

e.stopPropagation();
};
}

Expand Down
8 changes: 8 additions & 0 deletions test/TestLayout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import Resizable from '../lib/Resizable';
import Draggable from 'react-draggable';
import ResizableBox from '../lib/ResizableBox';
import 'style-loader!css-loader!../css/styles.css';

Expand Down Expand Up @@ -54,6 +55,13 @@ export default class TestLayout extends React.Component<{}, {width: number, heig
<ResizableBox className="box" width={200} height={200} axis="none">
<span className="text">Not resizable ("none" axis).</span>
</ResizableBox>
<Draggable>
<div>
<ResizableBox className="box" width={200} height={200}>
<span className="text">Both resizable and draggable</span>
</ResizableBox>
</div>
</Draggable>
</div>
</div>
);
Expand Down