在 Fullcalendar 中,是否可以防止事件 'foo' 与事件 'bar' 重叠,但允许它与事件 'quux' 重叠?

In Fullcalendar, is it possible to prevent event 'foo' to overlap with event 'bar', but allow it to overlap with event 'quux'?

假设我在 Fullcalendar 中有 3 种事件类型,'foo'、'bar' 和 'quux'。 'foo' 和 'bar' 不能相互重叠,但是 'quux' 可以同时重叠 'foo' 和 'bar'。

这可能吗?如果是这样,我该如何实现?

https://fullcalendar.io/docs/eventOverlap 表示可以防止重叠,但这完全可以防止事件类型的重叠

您链接到的 eventOverlap 文档页面说

"If given a function, the function will be called every time there is a pair of intersecting events, whether upon a user drag or resize. The function must return true if the overlap should be allowed and false otherwise"

因此,在该函数中,您可以定义任何您喜欢的逻辑来决定是否允许重叠,包括检查事件的属性。因此,您可以编写代码来检查这两个事件是否为 "foo" 和 "bar",然后 returns 相应地做出响应。

天真的例子:

eventOverlap: function(stillEvent, movingEvent) {
  if (
    (stillEvent.title == "foo" && movingEvent.title == "bar")
    ||
    (stillEvent.title == "bar" && movingEvent.title == "foo")
  ) 
  {
    return false;
  }
  return true;
}