Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Fullcalendar 完整日历事件内容_Fullcalendar_Sticky - Fatal编程技术网

Fullcalendar 完整日历事件内容

Fullcalendar 完整日历事件内容,fullcalendar,sticky,Fullcalendar,Sticky,我正试图使Fullcalendar中的事件内容变得有粘性。当您在日历中滚动时,只要事件不在视图之外,事件的内容就应该可见 我尝试使用简单的css,但不起作用,请参见: .fc-event .fc-content { position:sticky; top:0; } 有人知道如何让它工作吗?这不是很容易吗?不可能使用position:sticky-out-of-the-box,但下面是一个关于如何使用js的示例(将此添加到脚本末尾): 显然,选择器和顶部值非常具体。您可以使用js计算

我正试图使Fullcalendar中的事件内容变得有粘性。当您在日历中滚动时,只要事件不在视图之外,事件的内容就应该可见

我尝试使用简单的css,但不起作用,请参见:

.fc-event .fc-content {
  position:sticky;
  top:0;
}


有人知道如何让它工作吗?这不是很容易吗?

不可能使用position:sticky-out-of-the-box,但下面是一个关于如何使用js的示例(将此添加到脚本末尾):


显然,选择器和顶部值非常具体。您可以使用js计算每个事件的适当顶部距离,并将其应用于每个滚动过程。不过这是一个很大的工作。

添加了一个新的答案。如果合适的话,告诉我。谢谢你的回答。如果实施这种行为有那么困难,我就不做了。如果日历中有许多事件,则滚动时会对所有事件进行许多计算。这会导致应用程序性能不佳。
const content = document.querySelectorAll('.fc-event .fc-content')[1];
const scroller = document.querySelector('.fc-scroller');
scroller.addEventListener("scroll", function() {
    if (scroller.scrollTop > 100) {             
        content.style.position = "fixed";
        content.style.top = "130px";
    }
    else {
        content.style.position = "unset";               
    }
});