Use Destructuring variables to avoid repetitions

- Easier to read and write
- Also fixes fullscreen when leaving the viewer, my bad
This commit is contained in:
2020-03-31 10:35:51 +02:00
parent 2dc51a167a
commit 5ac5d6803f
5 changed files with 46 additions and 42 deletions

View File

@@ -16,10 +16,7 @@
let closed = false
// Wait for fullscreen store value
$: {
if ($fullscreen) openFullscreen($fullscreen)
else closeFullscreen()
}
$: if ($fullscreen) openFullscreen($fullscreen)
/*
@@ -27,13 +24,14 @@
*/
// Open fullscreen
const openFullscreen = throttle(currentPhoto => {
const { name, image, location } = currentPhoto
loading = true
if (!open) {
const img = document.createElement('img')
const imgContainer = scope.querySelector('.fullscreen__image')
img.src = getThumbnail(currentPhoto.image.private_hash, null, 1600, 'crop', 80)
img.alt = `${currentPhoto.name}, ${currentPhoto.location.name}, ${currentPhoto.location.country.name}`
img.src = getThumbnail(image.private_hash, null, 1600, 'crop', 80)
img.alt = `${name}, ${location.name}, ${location.country.name}`
img.width = 2400
img.height = 1600
imgContainer.append(img)