Reputation: 797
I'm using FullCalendar libraries to build a schedule. I have enabled editable
attribute, so I can resize the events. I use this event listener to do what I want to do:
eventResize: function(event,dayDelta,minuteDelta,allDay,revertFunc) {
//Some code goes here
}
But I want to know if there is a way to detect if the resize took place at the Start date of the event, or at the End date?
Upvotes: 0
Views: 896
Reputation: 1055
This code is more efficently:
eventResizeStart: function(event) {
startDateOnStart = event.start.format();
endDateOnStart = event.end.format();
},
eventResize: function( event, delta, revertFunc, jsEvent, ui, view ) {
startDateOnStop = event.start.format();
endDateOnStop = event.end.format();
if (startDateOnStart != startDateOnStop){
alert ('The resize took place at Start!');
} else if (endDateOnStart != endDateOnStop ){
alert ('The resize took place at End!');
}
}
Upvotes: 1
Reputation: 797
Well, I found the solution by myself. We can just keep records for the event period on eventResizeStart
and eventResizeStop
and then we compare these records. I mean something like this:
eventResizeStart: function(event) {
startDateOnStart = event.start;
endDateOnStart = event.end;
}
then
eventResizeStop: function(event) {
// I added 1 sec delay because in my experience the event object needs some time to update.
setTimeout(
function(){
startDateOnStop = event.start;
endDateOnStop = event.end;
//Now let's compare the dates.
if (startDateOnStart != startDateOnStop){
alert ('The resize took place at Start!');
// Do some things here.
} else if (endDateOnStart != endDateOnStop ){
alert ('The resize took place at End!');
}
}, 1000);
}
Upvotes: 1