From 8d0987a4c0de10585803a86e611a214d2ab2d4bd Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Tue, 13 Apr 2021 13:32:23 +0100 Subject: [PATCH] Centralize timeline for the first event in that day --- src/app/pages/agenda/agenda.page.ts | 57 +++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index 11f7f0844..9d0cac955 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -351,6 +351,7 @@ export class AgendaPage implements OnInit { }) } catch (error) { // + this.selectFirstEventOfTheDay(); } }, timeout); @@ -511,6 +512,8 @@ export class AgendaPage implements OnInit { loadRangeEvents(startTime: Date, endTime: Date){ + this.eventSelectedDate = new Date(startTime); + this.showLoader = true; if(window.innerWidth < 1024){ @@ -540,7 +543,8 @@ export class AgendaPage implements OnInit { allDay: false, event: element, calendarName: element.CalendarName, - profile: 'md' + profile: 'md', + id: element.EventId, }); }); @@ -579,7 +583,8 @@ export class AgendaPage implements OnInit { allDay: false, event: element, calendarName: element.CalendarName, - profile: 'pr' + profile: 'pr', + id: element.EventId, }); }); @@ -625,7 +630,8 @@ export class AgendaPage implements OnInit { allDay: false, event: element, calendarName: element.CalendarName, - profile: 'md' + profile: 'md', + id: element.EventId, }); }); @@ -657,7 +663,8 @@ export class AgendaPage implements OnInit { endTime: new Date(element.EndDate), allDay: false, event: element, - profile: 'pr' + profile: 'pr', + id: element.EventId, }); }); @@ -696,7 +703,8 @@ export class AgendaPage implements OnInit { endTime: new Date(element.EndDate), allDay: false, event: element, - profile: 'md' + profile: 'md', + id: element.EventId, }); }); @@ -725,7 +733,8 @@ export class AgendaPage implements OnInit { endTime: new Date(element.EndDate), allDay: false, event: element, - profile: 'pr' + profile: 'pr', + id: element.EventId, }); }); @@ -783,7 +792,8 @@ export class AgendaPage implements OnInit { allDay: false, event: element, calendarName: element.CalendarName, - profile: 'md' + profile: 'md', + id: element.EventId, }); }); @@ -826,7 +836,8 @@ export class AgendaPage implements OnInit { allDay: false, event: element, calendarName: element.CalendarName, - profile:'pr' + profile:'pr', + id: element.EventId, }); }); @@ -842,12 +853,42 @@ export class AgendaPage implements OnInit { this.centralizeTimeline(500); 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(){} doRefresh(ev: any){