Skip to content

Commit fef2465

Browse files
committed
Adding support for zIndex
1 parent c15afa1 commit fef2465

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/draggable.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ module.exports = React.createClass({
103103
*/
104104
cancel: React.PropTypes.string,
105105

106+
/**
107+
* `zIndex` to use while dragging.
108+
*
109+
* Example:
110+
*
111+
* ```jsx
112+
* var App = React.createClass({
113+
* render: function () {
114+
* return (
115+
* <Draggable zIndex={100}>
116+
* <div>I have a zIndex</div>
117+
* </Draggable>
118+
* );
119+
* }
120+
* });
121+
* ```
122+
*/
123+
zIndex: React.PropTypes.number,
124+
106125
/**
107126
* Called when dragging starts.
108127
*
@@ -169,6 +188,7 @@ module.exports = React.createClass({
169188
axis: 'both',
170189
handle: null,
171190
cancel: null,
191+
zIndex: NaN,
172192
onStart: emptyFunction,
173193
onDrag: emptyFunction,
174194
onStop: emptyFunction
@@ -241,6 +261,10 @@ module.exports = React.createClass({
241261
left: canDragX(this) ? this.state.clientX : this.state.startX
242262
};
243263

264+
if (this.state.dragging && !isNaN(this.props.zIndex)) {
265+
style.zIndex = this.props.zIndex;
266+
}
267+
244268
// Reuse the child provided
245269
// This makes it flexible to use whatever element is wanted (div, ul, etc)
246270
var child = null;

0 commit comments

Comments
 (0)