vis.js时间轴如何查看当前是否有约会

vis.js timeline how to check if there is currently an appointment

项目启动时是否会触发事件或类似事件?

好吧,基本上我想要的是一个在红线穿过时触发的事件(或其他有效的东西),在这个例子中,10:00am。

嗯,红线就是当前时间。您可以设置一个时间间隔,比方说,每次触发 3 秒,然后检查您是否有任何时间线项目越过这条线。像这样的伪代码:

var timeline = ... // This is the timeline object

setInterval(function() {
    var now = new Date(); // This is the current position of the timeline
    for (var d in timeline.itemsData._data) {
         if (d.start <= now && d.end >= now) { // this means the red line is crossing this item
             // do something...
         }
    }
}, 3); // each 3 seconds

代码不完整。但这是主要思想。

哦,我忘了关闭这个问题。 遗憾的是,没有 API,但是一个简单的超时就可以了。

setTimeout(function () {
   //do stuff on appointment begin
   setTimeout(function () {
       //do something when finished
   }, end - Date.now());
}, start - now);

Ps。每次约会都必须这样做。