Skip to content

Commit ab93c8c

Browse files
committed
Change bounds to be more intuitive.
1 parent 77e7ee1 commit ab93c8c

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ var App = React.createClass({
7777
// `bounds` specifies movement boundaries. Pass:
7878
// - 'parent' restricts movement within the node's offsetParent
7979
// (nearest node with position relative or absolute), or
80-
// - An object with left, top, right, and bottom properties.
80+
// - An object with left, top, right, and bottom properties. These indicate how far in each direction
81+
// the draggable can be moved. See example/index.html for more on this.
8182
//
8283
// `zIndex` specifies the zIndex to use while dragging.
8384
//

example/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ <h1>React Draggable</h1>
108108
<Draggable grid={[50, 50]}>
109109
<div className="box">I snap to a 50 x 50 grid</div>
110110
</Draggable>
111-
<Draggable bounds={{top: 0, left: 0, right: 300, bottom: 300}} zIndex={5}>
112-
<div className="box">I can only be moved within 300px bounds.</div>
111+
<Draggable bounds={{top: -100, left: -100, right: 100, bottom: 100}} zIndex={5}>
112+
<div className="box">I can only be moved 100px in any direction.</div>
113113
</Draggable>
114114
<div className="box" style={{height: '500px', width: '500px', position: 'relative'}}>
115115
<Draggable bounds="parent">

lib/draggable.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ function getBoundPosition(draggable, clientX, clientY) {
185185
right: innerWidth(parent) - outerWidth(node) - node.offsetLeft,
186186
bottom: innerHeight(parent) - outerHeight(node) - node.offsetTop
187187
};
188-
} else {
189-
if (isNum(bounds.right)) bounds.right -= outerWidth(node);
190-
if (isNum(bounds.bottom)) bounds.bottom -= outerHeight(node);
191188
}
192189

193190
// Keep x and y below right and bottom limits...

0 commit comments

Comments
 (0)