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

China☆狼群 提交于 2020-01-17 06:15:28

问题


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?


回答1:


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!');
             }
        }



回答2:


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);                   
}


来源:https://stackoverflow.com/questions/35181703/fullcalendar-detect-if-resize-was-on-start-or-on-end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!