Skip to content

Commit

Permalink
fixed bounding box undefined when resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Sep 11, 2023
1 parent 1b05a90 commit 1c86efb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/stores/app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { defineStore, storeToRefs } from 'pinia'
import { ref } from 'vue'
import { computed, ref } from 'vue'
import { watchOnce } from '@vueuse/core'
import { useCluster } from './cluster'

export const useApp = defineStore('app', () => {
// We just track the first load, so we can show a loading indicator
const firstLocationsLoaded = ref(false)
const isListShown = ref(false)
const mapLoaded = ref(false)
const showSplashScreen = computed(() => !mapLoaded.value || !firstLocationsLoaded.value)

const { singles, clusters } = storeToRefs(useCluster())

Expand All @@ -27,5 +29,7 @@ export const useApp = defineStore('app', () => {
isListShown,
shouldShowSearchBoxHint,
hideSearchBoxHint,
mapLoaded,
showSplashScreen,
}
})
2 changes: 1 addition & 1 deletion src/stores/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const useCluster = defineStore('cluster', () => {
const item: LocationClusterSet | undefined = memoized.get(key)

// If the item exists and the bounding box is within the memoized area, we can reuse the memoized item and there is no need to re-cluster
const needsToUpdate = !item || !bBoxIsWithinArea(boundingBox.value!, item.memoizedArea)
const needsToUpdate = !item || !boundingBox.value || !bBoxIsWithinArea(boundingBox.value, item.memoizedArea)

// Update the memoized item if it exists
if (!needsToUpdate) {
Expand Down
2 changes: 2 additions & 0 deletions src/stores/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const useMap = defineStore('map', () => {
}

function onBoundsChanged() {
if (!map.value || !map.value.getBounds())
return
boundingBox.value = boundsToBox(map.value!.getBounds())
updateRouteDebouncer()

Expand Down

0 comments on commit 1c86efb

Please sign in to comment.