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

implement callback on initializing drag or resize action #1206

Merged
merged 3 commits into from
Apr 18, 2019
Merged
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
1 change: 1 addition & 0 deletions examples/demos/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Dnd extends React.Component {
resizable
onEventResize={this.resizeEvent}
onSelectSlot={this.newEvent}
onDragStart={console.log}
defaultView={BigCalendar.Views.MONTH}
defaultDate={new Date(2015, 3, 12)}
/>
Expand Down
8 changes: 7 additions & 1 deletion src/addons/dragAndDrop/withDragAndDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import { mergeComponents } from './common'
*
* Set `resizable` to true in your calendar if you want events to be resizable.
*
* The HOC adds `onEventDrop` and `onEventResize` callback properties if the events are
* The HOC adds `onEventDrop`, `onEventResize`, `onDragStart` callback properties if the events are
* moved or resized. They are called with these signatures:
*
* ```js
* function onEventDrop({ event, start, end, allDay }) {...}
* function onEventResize(type, { event, start, end, allDay }) {...} // type is always 'drop'
* function onDragStart({ event, action, direction }) {...}
* ```
*
* Moving and resizing of events has some subtlety which one should be aware of.
Expand All @@ -53,6 +54,7 @@ export default function withDragAndDrop(Calendar) {
static propTypes = {
onEventDrop: PropTypes.func,
onEventResize: PropTypes.func,
onDragStart: PropTypes.func,

draggableAccessor: accessor,
resizableAccessor: accessor,
Expand Down Expand Up @@ -114,7 +116,11 @@ export default function withDragAndDrop(Calendar) {
}

handleBeginAction = (event, action, direction) => {
const { onDragStart } = this.props
this.setState({ event, action, direction })
if (onDragStart) {
onDragStart({ event, action, direction })
}
}

handleInteractionStart = () => {
Expand Down