Code clean

This commit is contained in:
2020-03-27 11:14:16 +01:00
parent b77f67d3b3
commit ebf1d99645
4 changed files with 29 additions and 28 deletions

View File

@@ -36,20 +36,20 @@
currentIndex = photos.findIndex(photo => photo.slug === init.params.photo)
}
// Change the current index depending on direction
const goToPhoto = direction => {
if (direction === 'prev') {
// Change current index from param
const goToPhoto = to => {
if (to === 'prev') {
currentIndex--
currentIndex = (currentIndex < 0) ? photos.length - 1 : currentIndex
} else if (direction === 'next') {
} else if (to === 'next') {
currentIndex++
currentIndex = (currentIndex >= photos.length) ? 0 : currentIndex
} else {
currentIndex = direction
currentIndex = to
}
// Send current photo to event
sendCurrentPhoto({ init: false })
// Dispatch current photo
sendCurrentPhoto()
}
// Send current photo to event
@@ -94,7 +94,7 @@
/*
** Run code on browser only
** Run code when mounted
*/
onMount(() => {
// Entering transition
@@ -124,7 +124,7 @@
}
}
// Send current photo to event for init
// Dispatch current photo for init
sendCurrentPhoto({ init: true })
})
</script>