Fix unnecessary "hops" after zooming
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good

This commit is contained in:
Willem Dantuma 2020-03-26 15:55:21 +01:00
parent dad8e061ea
commit 050fda377b

View File

@ -178,7 +178,6 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
let rotation = parseFloat(params.get("rotation")); let rotation = parseFloat(params.get("rotation"));
let baseLayer = params.get("baseLayer")?params.get("baseLayer"):""; let baseLayer = params.get("baseLayer")?params.get("baseLayer"):"";
newMapState = { xCenter: xCenter, yCenter: yCenter, zoom: zoom, rotation: rotation, baseLayerCode: baseLayer } newMapState = { xCenter: xCenter, yCenter: yCenter, zoom: zoom, rotation: rotation, baseLayerCode: baseLayer }
mapStateChanged = (JSON.stringify(lastMapState) != JSON.stringify(newMapState));
window.localStorage.setItem("FarmMapsCommonMap_mapState",JSON.stringify(newMapState)); window.localStorage.setItem("FarmMapsCommonMap_mapState",JSON.stringify(newMapState));
} }
if (params.has("queryState")) { if (params.has("queryState")) {
@ -194,12 +193,10 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
if(setStateCount==0) t=600; if(setStateCount==0) t=600;
setTimeout(() => { setTimeout(() => {
this.zone.run(()=> { this.zone.run(()=> {
if ( (queryStateChanged && mapStateChanged) || setStateCount ==0) { if (setStateCount ==0) {
this.store.dispatch(new mapActions.SetState(newMapState,newQueryState)); this.store.dispatch(new mapActions.SetState(newMapState,newQueryState));
} else if(queryStateChanged) { } else if(queryStateChanged) {
this.store.dispatch(new mapActions.SetQueryState(newQueryState)); this.store.dispatch(new mapActions.SetQueryState(newQueryState));
} else if (mapStateChanged) {
this.store.dispatch(new mapActions.SetMapState(newMapState));
} }
}) })
},t); },t);