Fix location page error and message style

This commit is contained in:
2022-07-15 20:43:22 +02:00
parent ff128c40a1
commit 9328b9d879
2 changed files with 33 additions and 17 deletions

View File

@@ -118,24 +118,26 @@
})
// Photos MutationObserver
mutationPhotos = new MutationObserver((mutationsList) => {
// When adding new childs
for (const mutation of mutationsList) {
if (mutation.type === 'childList') {
// Observe new items
Array.from(mutation.addedNodes)
.filter(item => item.nodeType === Node.ELEMENT_NODE)
.forEach((item: HTMLElement) => observerPhotos.observe(item))
if (photos.length) {
mutationPhotos = new MutationObserver((mutationsList) => {
// When adding new childs
for (const mutation of mutationsList) {
if (mutation.type === 'childList') {
// Observe new items
Array.from(mutation.addedNodes)
.filter(item => item.nodeType === Node.ELEMENT_NODE)
.forEach((item: HTMLElement) => observerPhotos.observe(item))
}
}
}
})
mutationPhotos.observe(photosListEl, {
childList: true,
})
})
mutationPhotos.observe(photosListEl, {
childList: true,
})
// Observe existing elements
const existingPhotos = photosListEl.querySelectorAll('.house')
existingPhotos.forEach(el => observerPhotos.observe(el))
// Observe existing elements
const existingPhotos = photosListEl.querySelectorAll('.house')
existingPhotos.forEach(el => observerPhotos.observe(el))
}
/**
@@ -191,7 +193,7 @@
<Metas
title="Houses Of {location.name}"
description="Discover {totalPhotos} beautiful homes from {location.name}, {location.country.name}"
image={getAssetUrlKey(latestPhoto.image.id, 'share-image')}
image={latestPhoto ? getAssetUrlKey(latestPhoto.image.id, 'share-image') : null}
/>
<svelte:window bind:scrollY />