Dionis Beqiraj
Dionis Beqiraj

Reputation: 797

FullCalendar: Detect if resize was on Start or on End.

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

Answers (2)

Giuseppe Lodi Rizzini
Giuseppe Lodi Rizzini

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

Dionis Beqiraj
Dionis Beqiraj

Reputation: 797

Well, I found the solution by myself. We can just keep records for the event period on eventResizeStart and eventResizeStopand 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

Related Questions