版本:Fullcalendar-schedualer v5 beta2
我发现在“ resouceTimeline”视图下,当多个事件连续并且事件中有很多文本时,发生显示错误:两个事件重叠。
注意:我的设置是,无论每个事件的开始时间或结束时间如何,它们的长度都是相同的,即一整天的时间
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
schedulerLicenseKey: '0974280307-fcs-1531751880',
locale: 'fr',
headerToolbar: {
left: 'today prev,next',
center: 'title',
right: 'resourceTimelineThreeDays,timeGridWeek,dayGridMonth'
},
initialView: 'resourceTimelineThreeDays',
eventDisplay: "block",
resourceAreaWidth: '15%',
selectable: true,
navLinks: true,
weekNumbers: true,
expandRows: true,
allDaySlot: false,
slotMinTime: '08:00:00',
slotMaxTime: '19:00:00',
timeFormat: 'H:mm',
views: {
resourceTimelineThreeDays: {
type: 'resourceTimeline',
duration: { days: 7 },
buttonText: '7 days',
slotLabelInterval: { days: 1 }
}
},
resourceAreaHeaderContent: 'Rooms',
resourceLabelContent: function(arg) {
return 'Auditorium ' + arg.resource.id.toUpperCase();
},
resourceLabelDidMount: function(arg) {
if (arg.resource.id == 'h') {
arg.el.style.backgroundColor = 'rgb(255, 243, 206)';
}
},
resources: [
{ id: 'a' },
{ id: 'b', eventColor: 'green' },
{ id: 'c', eventColor: 'orange' },
{ id: 'd' },
{ id: 'e' },
{ id: 'f', eventColor: 'red' },
{ id: 'g' },
{ id: 'h' },
{ id: 'i' },
{ id: 'j' },
{ id: 'k' },
{ id: 'l' },
{ id: 'm' },
{ id: 'n' },
{ id: 'o' },
{ id: 'p' },
{ id: 'q' },
{ id: 'r' },
{ id: 's' },
{ id: 't' },
{ id: 'u' },
{ id: 'v' },
{ id: 'w' },
{ id: 'x' },
{ id: 'y' },
{ id: 'z' }
],
events: [
{ id: '1', resourceId: 'b', start: '2020-05-12T02:00:00', end: '2020-05-12T07:00:00', title: 'event 1', customContent: "<br><b>Breaking news :</b> <br> test test test test test test<br><b>Intervenants :</b> <br> david stephan<br>david stephan<br><b>Support :</b> Etablissement<br><b>status :</b> prevue" },
{ id: '2', resourceId: 'b', start: '2020-05-12T09:00:00', end: '2020-05-12T22:00:00', title: 'event 2', customContent: "<br><b>Breaking news :</b> <br> test test test test test test<br><b>Intervenants :</b> <br>david stephan<br><b>Support :</b> Etablissement<br><b>status :</b> prevue" },
{ id: '3', resourceId: 'b', start: '2020-05-12', end: '2020-05-12', title: 'event 3', customContent: "<br><b>Breaking news :</b> <br> test test test test test test<br><b>Intervenants :</b> <br> david stephan<br>david stephan<br><b>Support :</b> Etablissement<br><b>status :</b> prevue" },
{ id: '4', resourceId: 'b', start: '2020-05-13T03:00:00', end: '2020-05-13T08:00:00', title: 'event 4' , customContent: "<br><b>Breaking news :</b> <br> test test test test test test<br><b>Intervenants :</b> <br> david stephan<br>david stephan<br><b>Support :</b> Etablissement<br><b>status :</b> prevue"},
{ id: '5', resourceId: 'b', start: '2020-05-14T00:30:00', end: '2020-05-14T02:30:00', title: 'event 5', customContent: "<br><b>Breaking news :</b> <br> test test test test test test<br><b>Intervenants :</b> <br> david stephan<br>david stephan<br><b>Support :</b> Etablissement<br><b>status :</b> prevue" }
],
eventContent: function(arg) {
var view = arg.view;
var event = arg.event;
var eventExtendedProps = event.extendedProps;
var domTime = document.createElement('div');
if(event.start.getMinutes() != 0){
domTime.textContent = event.start.getHours()+":"+event.start.getMinutes();
}else{
domTime.textContent = event.start.getHours();
}
domTime.setAttribute('class', 'fc-event-time');
var domTitle = document.createElement('div');
domTitle.textContent = event.title;
domTitle.setAttribute('class', 'fc-event-title');
var arrayOfDomNodes = [ domTime, domTitle ]
return { domNodes: arrayOfDomNodes }
contentHTML = "<div class='fc-event-time'>"+domTimeContent+"</div><div class='fc-event-title'>"+event.title+"</div>";
return { html: contentHTML}
},
eventDidMount: function(arg) {
var eee = arg.event.extendedProps;
var domCustom = document.createElement('div');
domCustom.innerHTML = eee.customContent;
domCustom.setAttribute('class', 'fc-event-description');
arg.el.appendChild(domCustom);
}
});
calendar.render();
});
body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 14px;
}
#calendar {
max-width: 1100px;
margin: 50px auto;
}
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='https://unpkg.com/fullcalendar-scheduler@5.0.0-beta.2/main.min.css' rel='stylesheet' />
<script src='https://unpkg.com/fullcalendar-scheduler@5.0.0-beta.2/main.min.js'></script>
</head>
<body>
<div id='calendar'></div>
</body>
</html>