javascript - Full calendar - Drag and Drop - Customisation - Stack Overflow

I'm using React scheduler - FullCalendar. I like to keep the drag-and-drop feature for changing th

I'm using React scheduler - FullCalendar. I like to keep the drag-and-drop feature for changing the event from one resource to another. But is there a way to disable dragging horizontally to change time?

Also right now, the drag and drop works like the event will stick from one resource to another, and there is no smooth drag action. Can someone help me figure out a way to implement smooth drag and drop (Event will follow the mouse) in FullCalendar if it's possible?

  1. Disable drag and drop horizontally (Avoid changing time)
  2. Smooth drag and drop instead of sticking from one portion to another

Version: 5.1 Full Calendar | Reactjs

PS: I need to drag disabled horizontally, user shouldn't even be able to start dragging, (Logics like check on dragEnd will not work)

I'm using React scheduler - FullCalendar. I like to keep the drag-and-drop feature for changing the event from one resource to another. But is there a way to disable dragging horizontally to change time?

Also right now, the drag and drop works like the event will stick from one resource to another, and there is no smooth drag action. Can someone help me figure out a way to implement smooth drag and drop (Event will follow the mouse) in FullCalendar if it's possible?

  1. Disable drag and drop horizontally (Avoid changing time)
  2. Smooth drag and drop instead of sticking from one portion to another

Version: 5.1 Full Calendar | Reactjs

PS: I need to drag disabled horizontally, user shouldn't even be able to start dragging, (Logics like check on dragEnd will not work)

Share Improve this question edited Oct 25, 2022 at 7:57 Victor asked Jul 6, 2020 at 9:31 VictorVictor 4,2091 gold badge32 silver badges37 bronze badges 1
  • Ended up writing patches for the library using patch-package – Victor Commented Jun 8, 2021 at 13:52
Add a ment  | 

1 Answer 1

Reset to default 5

1. Disable drag and drop horizontally (Avoid changing time)

You can use onDrop and you can get start and end time using info.event and info.oldEvent respectively.

Working demo

     <FullCalendar
            editable={true}
            defaultView="timeGridWeek"
            headerToolbar={{
              left: "prev,next today",
              center: "title",
              right: "dayGridMonth,timeGridWeek,timeGridDay"
            }}
            header={{
              left: "prev,next today",
              center: "title",
              right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek"
            }}
            plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
            ref={this.calendarComponentRef}
            weekends={this.state.calendarWeekends}
            events={this.state.calendarEvents}
            dateClick={this.handleDateClick}
            eventDrop={info => {//<--- see from here
              const { start, end } = info.oldEvent._instance.range;
              console.log(start, end);
              const {
                start: newStart,
                end: newEnd
              } = info.event._instance.range;
              console.log(newStart, newEnd);
              if (new Date(start).getDate() === new Date(newStart).getDate()) {
                info.revert();
              }
            }}
          />

2. Smooth drag and drop instead of sticking from one portion to another

Couldn't find a quick take away solution. I can solve this but needs a bit more time to figure-out a solution. If i have time, I will e back later and update the answer.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745431043a4627390.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信