Centralize timeline for the first event in that day

This commit is contained in:
Peter Maquiran
2021-04-13 13:32:23 +01:00
parent a8a96c5a04
commit 8d0987a4c0
+49 -8
View File
@@ -351,6 +351,7 @@ export class AgendaPage implements OnInit {
}) })
} catch (error) { } catch (error) {
// //
this.selectFirstEventOfTheDay();
} }
}, timeout); }, timeout);
@@ -511,6 +512,8 @@ export class AgendaPage implements OnInit {
loadRangeEvents(startTime: Date, endTime: Date){ loadRangeEvents(startTime: Date, endTime: Date){
this.eventSelectedDate = new Date(startTime);
this.showLoader = true; this.showLoader = true;
if(window.innerWidth < 1024){ if(window.innerWidth < 1024){
@@ -540,7 +543,8 @@ export class AgendaPage implements OnInit {
allDay: false, allDay: false,
event: element, event: element,
calendarName: element.CalendarName, calendarName: element.CalendarName,
profile: 'md' profile: 'md',
id: element.EventId,
}); });
}); });
@@ -579,7 +583,8 @@ export class AgendaPage implements OnInit {
allDay: false, allDay: false,
event: element, event: element,
calendarName: element.CalendarName, calendarName: element.CalendarName,
profile: 'pr' profile: 'pr',
id: element.EventId,
}); });
}); });
@@ -625,7 +630,8 @@ export class AgendaPage implements OnInit {
allDay: false, allDay: false,
event: element, event: element,
calendarName: element.CalendarName, calendarName: element.CalendarName,
profile: 'md' profile: 'md',
id: element.EventId,
}); });
}); });
@@ -657,7 +663,8 @@ export class AgendaPage implements OnInit {
endTime: new Date(element.EndDate), endTime: new Date(element.EndDate),
allDay: false, allDay: false,
event: element, event: element,
profile: 'pr' profile: 'pr',
id: element.EventId,
}); });
}); });
@@ -696,7 +703,8 @@ export class AgendaPage implements OnInit {
endTime: new Date(element.EndDate), endTime: new Date(element.EndDate),
allDay: false, allDay: false,
event: element, event: element,
profile: 'md' profile: 'md',
id: element.EventId,
}); });
}); });
@@ -725,7 +733,8 @@ export class AgendaPage implements OnInit {
endTime: new Date(element.EndDate), endTime: new Date(element.EndDate),
allDay: false, allDay: false,
event: element, event: element,
profile: 'pr' profile: 'pr',
id: element.EventId,
}); });
}); });
@@ -783,7 +792,8 @@ export class AgendaPage implements OnInit {
allDay: false, allDay: false,
event: element, event: element,
calendarName: element.CalendarName, calendarName: element.CalendarName,
profile: 'md' profile: 'md',
id: element.EventId,
}); });
}); });
@@ -826,7 +836,8 @@ export class AgendaPage implements OnInit {
allDay: false, allDay: false,
event: element, event: element,
calendarName: element.CalendarName, calendarName: element.CalendarName,
profile:'pr' profile:'pr',
id: element.EventId,
}); });
}); });
@@ -842,12 +853,42 @@ export class AgendaPage implements OnInit {
this.centralizeTimeline(500); this.centralizeTimeline(500);
this.showLoader = false; this.showLoader = false;
this.selectFirstEventOfTheDay();
}); });
} }
} }
// for timeline select the first event in the timeline
selectFirstEventOfTheDay(){
setTimeout(()=>{
let sortedDate = this.eventSource.sort((a,b) =>{
return (b.startTime) -(a.startTime);
});
let filterDate = sortedDate.filter((e) => {
return e.startTime.toLocaleDateString('en-US') == this.eventSelectedDate.toLocaleDateString('en-US');
});
const firstEventStartHours = new Date(filterDate[filterDate.length - 1].startTime).getHours();
const scrollContainer = document.querySelector('.timeline-wrapper');
scrollContainer.scroll({
top: firstEventStartHours*60,
left: 0,
behavior: 'smooth'
})
}, 200);
}
actions(){} actions(){}
doRefresh(ev: any){ doRefresh(ev: any){