forked from MapComplete/MapComplete
		
	UX: move minimap into a 'delayedComponent' to give a smoother feeling to opening popups
This commit is contained in:
		
							parent
							
								
									b22015e2c8
								
							
						
					
					
						commit
						3547cb7c92
					
				
					 2 changed files with 30 additions and 3 deletions
				
			
		
							
								
								
									
										21
									
								
								src/UI/Base/DelayedComponent.svelte
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/UI/Base/DelayedComponent.svelte
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | ||||||
|  | <script lang="ts"> | ||||||
|  |   import { Utils } from "../../Utils" | ||||||
|  |   import Loading from "./Loading.svelte" | ||||||
|  | 
 | ||||||
|  |   /** | ||||||
|  |    * Some components are slow to load | ||||||
|  |    * This item draws a 'loading' and will only start loading after a few milliseconds | ||||||
|  |    */ | ||||||
|  |   export let timeout = 200 | ||||||
|  |   let timeoutReached = false | ||||||
|  |   Utils.waitFor(timeout).then(() => { | ||||||
|  |     timeoutReached = true | ||||||
|  |   }) | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | {#if timeoutReached} | ||||||
|  |   <slot /> | ||||||
|  | {:else } | ||||||
|  |   <Loading cls="h-full w-full flex justify-center items-center low-interaction"/> | ||||||
|  | {/if} | ||||||
|  | @ -7,6 +7,9 @@ | ||||||
|   import ShowDataLayer from "../Map/ShowDataLayer" |   import ShowDataLayer from "../Map/ShowDataLayer" | ||||||
|   import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource" |   import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource" | ||||||
|   import MaplibreMap from "../Map/MaplibreMap.svelte" |   import MaplibreMap from "../Map/MaplibreMap.svelte" | ||||||
|  |   import Loading from "../Base/Loading.svelte" | ||||||
|  |   import { Utils } from "../../Utils" | ||||||
|  |   import DelayedComponent from "../Base/DelayedComponent.svelte" | ||||||
| 
 | 
 | ||||||
|   export let state: SpecialVisualizationState |   export let state: SpecialVisualizationState | ||||||
|   export let tagSource: UIEventSource<Record<string, string>> |   export let tagSource: UIEventSource<Record<string, string>> | ||||||
|  | @ -47,7 +50,7 @@ | ||||||
|       } |       } | ||||||
|       return features |       return features | ||||||
|     }, |     }, | ||||||
|     [tagSource] |     [tagSource], | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
|   let mlmap = new UIEventSource(undefined) |   let mlmap = new UIEventSource(undefined) | ||||||
|  | @ -73,10 +76,13 @@ | ||||||
|     mlmap, |     mlmap, | ||||||
|     new StaticFeatureSource(featuresToShow), |     new StaticFeatureSource(featuresToShow), | ||||||
|     state.theme.layers, |     state.theme.layers, | ||||||
|     { zoomToFeatures: true } |     { zoomToFeatures: true }, | ||||||
|   ) |   ) | ||||||
|  | 
 | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <div class="h-40 rounded" style="overflow: hidden; pointer-events: none;"> | <div class="h-40 rounded" style="overflow: hidden; pointer-events: none;"> | ||||||
|  |   <DelayedComponent> | ||||||
|     <MaplibreMap interactive={false} map={mlmap} mapProperties={mla} /> |     <MaplibreMap interactive={false} map={mlmap} mapProperties={mla} /> | ||||||
|  |   </DelayedComponent> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue