From 33c4d5424ba10567d0cafced80a7d984a60659ac Mon Sep 17 00:00:00 2001 From: Konstantinos Kamaropoulos Date: Mon, 2 Mar 2020 14:12:02 +0200 Subject: [PATCH] feat: Only fly to latest marker if there was a new one --- src/app/map/map.component.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts index fff3c12..53d6dae 100644 --- a/src/app/map/map.component.ts +++ b/src/app/map/map.component.ts @@ -50,8 +50,10 @@ export class MapComponent implements OnInit { } else { data = await this.logsService.getUpdates(); } + let newPointsCount = 0; for (let log of data) { if (log['gps_data']['status'] == 'A') { + newPointsCount++; let html = log['gps_data']['datestamp'] + ' ' + @@ -73,11 +75,13 @@ export class MapComponent implements OnInit { } this.lastPoint = [log['gps_data']['longitude'], log['gps_data']['latitude']]; } - this.map.flyTo({ - center: [this.lastPoint[0], this.lastPoint[1]], - essential: true, // this animation is considered essential with respect to prefers-reduced-motion - zoom: 22 - }); + if (newPointsCount) { + this.map.flyTo({ + center: [this.lastPoint[0], this.lastPoint[1]], + essential: true, // this animation is considered essential with respect to prefers-reduced-motion + zoom: 22 + }); + } }); } }