2017-10-06 26 views
1

我有一個VisJS時間表,範圍從2017年1月到2018年。時間表以年中三個月爲中心開放,但我希望每次都以當前時間爲中心開放。當前日期的公開時間表 - VisJS

min: new Date(2017, 1, 5),    // lower limit of visible range 
max: new Date(2018, 1, 11),    // upper limit of visible range 
zoomMin: 1000 * 60 * 60 * 24,   // one day in milliseconds 
zoomMax: 1000 * 60 * 60 * 24*31*3, // three months in milliseconds 

回答

0

您可以用這樣的嘗試(timeline.setWindow()):

const todayStart = new Date(); 
todayStart.setHours(8, 0, 0, 0); 
const todayEnd = new Date(); 
todayEnd.setHours(18, 0, 0, 0); 

console.log(todayStart, ':', todayEnd); 
setTimeout(_ => { 
    this.timeline.setWindow(todayStart, todayEnd, { animation: true }); 
}); 

或更好地與moveTo

this.timeline.moveTo(new Date());//or 
    this.timeline.moveTo(new Date(), { animation: true });//or 
    this.timeline.moveTo(new Date(), { animation: true }, (props) => { 
    console.log("movedTo", props); 
    }); 
+0

謝謝盧卡斯! – user7631026