-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated drag sources to new API. #16
- Loading branch information
1 parent
df76a3f
commit e59e3e6
Showing
3 changed files
with
43 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,33 @@ | ||
var React = require('react'), | ||
ReactDND = require('react-dnd'); | ||
|
||
var React = require('react'); | ||
var { DragSource } = require('react-dnd'); | ||
var ItemTypes = require('./ItemTypes.js'); | ||
|
||
var DraggableBlock = React.createClass({ | ||
mixins: [ReactDND.DragDropMixin], | ||
statics: { | ||
configureDragDrop: function(register) { | ||
register(ItemTypes.BLOCK, { | ||
dragSource: { | ||
beginDrag: function(component) { | ||
// TODO: use this to transfer data | ||
return { | ||
item: { | ||
} | ||
}; | ||
} | ||
} | ||
}); | ||
var blockSource = { | ||
beginDrag(props) { | ||
return { | ||
item: {} | ||
} | ||
}, | ||
render() { | ||
var style = {}; | ||
} | ||
}; | ||
|
||
var isDragging = this.getDragState(ItemTypes.BLOCK).isDragging; | ||
style.opacity = isDragging ? 0.4 : 1; | ||
function collect(connect, monitor) { | ||
return { | ||
connectDragSource: connect.dragSource(), | ||
isDragging: monitor.isDragging() | ||
} | ||
} | ||
|
||
var DraggableBlock = React.createClass({ | ||
render() { | ||
var { isDragging, connectDragSource } = this.props; | ||
|
||
return ( | ||
<div {...this.dragSourceFor(ItemTypes.BLOCK)} | ||
style={style} className="draggable"> | ||
return connectDragSource( | ||
<div style={{opacity: isDragging ? 0.4 : 1 }} className="draggable"> | ||
<i className="ion-plus-circled"></i> | ||
Block | ||
</div> | ||
) | ||
} | ||
}); | ||
|
||
module.exports = DraggableBlock; | ||
module.exports = DragSource(ItemTypes.BLOCK, blockSource, collect)(DraggableBlock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,33 @@ | ||
var React = require('react'), | ||
ReactDND = require('react-dnd'); | ||
|
||
var React = require('react'); | ||
var { DragSource } = require('react-dnd'); | ||
var ItemTypes = require('./ItemTypes'); | ||
|
||
var DraggableQuestion = React.createClass({ | ||
mixins: [ReactDND.DragDropMixin], | ||
statics: { | ||
configureDragDrop: function(register) { | ||
register(ItemTypes.QUESTION, { | ||
dragSource: { | ||
beginDrag: function(component) { | ||
// TODO: use this to transfer data | ||
return { | ||
item: { | ||
} | ||
}; | ||
} | ||
} | ||
}); | ||
var questionSource = { | ||
beginDrag(props) { | ||
return { | ||
item: {} | ||
} | ||
}, | ||
} | ||
}; | ||
|
||
function collect(connect, monitor) { | ||
return { | ||
connectDragSource: connect.dragSource(), | ||
isDragging: monitor.isDragging() | ||
} | ||
} | ||
|
||
var DraggableQuestion = React.createClass({ | ||
render() { | ||
var style = {}; | ||
var isDragging = this.getDragState(ItemTypes.QUESTION).isDragging; | ||
style.opacity = isDragging ? 0.4 : 1; | ||
var { isDragging, connectDragSource } = this.props; | ||
|
||
return ( | ||
<div {...this.dragSourceFor(ItemTypes.QUESTION)} | ||
style={style} className="draggable"> | ||
return connectDragSource( | ||
<div style={{opacity: isDragging ? 0.4 : 1}} className="draggable"> | ||
<i className="ion-plus-circled"></i> | ||
Question | ||
</div> | ||
) | ||
} | ||
}); | ||
|
||
module.exports = DraggableQuestion; | ||
module.exports = DragSource(ItemTypes.QUESTION, questionSource, collect)(DraggableQuestion); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters