重叠事件

时间:2017-10-19 11:48:31

标签: javascript jquery events fullcalendar overlap

我正在尝试为首先重叠的事件设置优先级。默认的fullcalendar与稍后时间启动的事件重叠。让我们说

我有两件事:

事件1 - time_start:11:00 time_end:11:05 事件2 - time_start:11:01 time_end:20:00

现在fullcalendar会重叠事件2,即使它的持续时间比第一个更长 - 这就是重点。我想说,事件2的优先级高于事件1.如果我说事件2与事件1同时启动,那么这些事件的显示将是正确的(如我所愿)。

代码笔上的示例1:https://codepen.io/anon/pen/RLvMrg?editors=0010 代码笔上的示例2(同一时间开始):https://codepen.io/anon/pen/NaoYvE?editors=0010

Fullcalendar初始化(没有事件数据):

    $(function() { // document ready

  $('#calendar').fullCalendar({
            header: {
                left: 'prev, title, next, today',
                center: '',
                right: 'dailyView, weeklyView'            },
            nowIndicator: true,
            columnFormat: 'dddd',    // like 'Monday', for day views
            defaultView: 'agendaWeek',
            editable: true,
            allDayDefault: false,
            displayEventTime: false,
            events: [],
            views: {
                agenda: {
                    allDaySlot: false,
                    slotDuration: '00:05:00',
                    slotLabelInterval: 5,
                    slotLabelFormat: 'HH(:mm)',
                    slotEventOverlap: true,
                    titleFormat: 'DD. MMMM YYYY'
                }
            },
            height: function () {

                console.log(window.innerWidth + "x" + window.innerHeight);

                var screenHeight = window.innerHeight;
                var heightRatio = 0.8;

                if (screenHeight >= 1200) {
                    heightRatio = 0.85;
                } else if (screenHeight >= 1080) {
                    heightRatio = 0.835;
                } else if (screenHeight >= 900 && screenHeight < 1080) {
                    heightRatio = 0.82;
                } else if (screenHeight >= 768 && screenHeight < 900) {
                    heightRatio = 0.77;
                } else if (screenHeight >= 590 && screenHeight < 900) {
                    heightRatio = 0.73;
                } else {
                    heightRatio = 0.68;
                }

                return $(window).height() * heightRatio;
            }
        });

});

屏幕截图示例1:screenshot for example 1

screenshot for example 2

有没有办法防止这种情况发生?我尝试使用slotEventOverlap属性以及将eventOverlap作为函数 - 但没有成功。

感谢您的帮助!

此致

0 个答案:

没有答案