vijs 时间线文档:https ://visjs.github.io/vis-timeline/docs/timeline/
我正在使用这个例子: https ://visjs.github.io/vis-timeline/examples/timeline/other/drag_drop.html
我想在时间线上放置一个范围项目,并设置我放置它的开始时间和一小时后的结束时间。
我有结束时间,没问题。
我正在使用此代码
function handleDragStart(event) {
var dragSrcEl = event.target;
event.dataTransfer.effectAllowed = 'move';
var item = {
id: new Date(),
type: 'range',
content: event.target.innerHTML.trim()
};
item.start = new Date();
item.end = new Date(1000*60*60 + (new Date()).valueOf());
event.dataTransfer.setData("text", JSON.stringify(item));
}
如果你看到: item.start = new Date(); 我得到的是实际时间,而不是我丢弃物品的时间。
我看到我可以有时间使用:
timeline.on('drop', function (properties) {
console.log(properties.time);
});
但我不能在函数中使用它。