首页 > 解决方案 > 鼠标悬停在fullcallendar时如何拖动事件

问题描述

我想在鼠标悬停时拖动事件,我尝试只调用触发器 mousedown 和 mousemove 但它的方法不起作用:

var calendar = new FullCalendar.Calendar(calendarEl, {
timeZone: 'UTC',
headerToolbar: {
  left: 'prev,next today',
  center: 'title',
  right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
editable: true,
dayMaxEvents: true, // when too many events in a day, show the popover
events: 'https://fullcalendar.io/demo-events.json?overload-day',
eventMouseEnter: function(info ){ // when mouse over
    console.log('eventMouseEnter')
    $(info.el).trigger('mousedown').trigger('mousemove') // it not worked
}

});

任何帮助请求,告诉我当鼠标悬停在 FulCallendar 时如何拖动事件?

https://jsfiddle.net/bemulima/2ma7dL9f/5/

标签: javascriptjqueryfullcalendar

解决方案


我找到了解决方案。也许这不是更好的解决方案,但它适用于自然模拟 mousedown。

eventMouseEnter: function(info ){
    console.log('eventMouseEnter')
    var evt = new MouseEvent("mousedown", {
                            view: window,
                            bubbles: true,
                            cancelable: true,
                            clientX: info.jsEvent.pageX,
                            clientY: info.jsEvent.pageY,
                            /* whatever properties you want to give it */
                        });
                        info.el.dispatchEvent(evt);
}

https://jsfiddle.net/bemulima/2ma7dL9f/7/


推荐阅读