Tweaks and fixes

This commit is contained in:
2020-02-17 22:36:36 +01:00
parent 6fb6937c1a
commit 0174ba08f2
8 changed files with 20 additions and 70 deletions

View File

@@ -6,7 +6,7 @@
// Preload data
export async function preload (page, session) {
// Load photos
const req = await this.fetch(`${apiEndpoints.rest}/items/photos?fields=id,name,date,slug,image.*,created_on,modified_on&filter[location.slug][rlike]=%${page.params.location}%&limit=-1&sort=-created_on,name`)
const req = await this.fetch(`${apiEndpoints.rest}/items/photos?fields=id,name,date,slug,image.*,location.*,location.country.*,created_on,modified_on&filter[location.slug][rlike]=%${page.params.location}%&limit=-1&sort=-created_on,name`)
const photos = await req.json()
if (req.status === 200) {
return { photos: photos.data }

View File

@@ -75,33 +75,12 @@
}
})
// Keyboard navigation
const keyboardNav = event => {
const keyCode = event.keyCode
switch (event.keyCode) {
case 37: case 80: case 74:
document.querySelector('.carousel__controls--area.prev').click()
break
case 39: case 78: case 75:
document.querySelector('.carousel__controls--area.next').click()
break
case 27: case 67:
document.getElementById('photo_close').click()
break
default: break
}
}
/*
** Run code on browser only
*/
onMount(() => {
changeWindowWidth = () => {
windowWidth = window.innerWidth
}
changeWindowWidth()
})
</script>
@@ -109,7 +88,7 @@
<title>Houses Of - photoName photoCountryName</title>
</svelte:head>
<svelte:window on:keydown={keyboardNav} on:resize={changeWindowWidth} />
<svelte:window bind:innerWidth={windowWidth} />
<section class="viewer">
<div class="viewer__top">
@@ -129,7 +108,7 @@
</div>
</div>
<Carousel viewer={true} {photos} />
<Carousel {photos} viewer={true} />
</section>