goToPhoto('prev')}
>
goToPhoto('next')}
>
currentIndex = event.detail.index}
+ on:goToIndex={event => currentIndex = event.detail}
/>
{/if}
diff --git a/src/organisms/Pagination.svelte b/src/organisms/Pagination.svelte
index a29bfe7..b36eeb5 100644
--- a/src/organisms/Pagination.svelte
+++ b/src/organisms/Pagination.svelte
@@ -22,9 +22,7 @@
photosToAppend.forEach(photo => photo.hidden = false)
// Merge new photos to show to the existing ones
- dispatch('updatePagination', {
- paginatedPhotos: [...paginatedPhotos, ...photosToAppend]
- })
+ dispatch('updatePagination', [...paginatedPhotos, ...photosToAppend])
// Increment current index
currentIndex = currentIndex + photosPerPage
diff --git a/src/routes/location/[country]/[place].svelte b/src/routes/location/[country]/[place].svelte
index afc2911..1f55718 100644
--- a/src/routes/location/[country]/[place].svelte
+++ b/src/routes/location/[country]/[place].svelte
@@ -80,7 +80,7 @@
let paginatedPhotos = photos.filter(photo => photo.hidden === false)
// Update pagination event from Pagination component
- const updatePagination = event => paginatedPhotos = event.detail.paginatedPhotos
+ const updatePagination = event => paginatedPhotos = event.detail
/*
diff --git a/src/routes/viewer/[country]/[place]/[photo].svelte b/src/routes/viewer/[country]/[place]/[photo].svelte
index a860b19..72ce03e 100644
--- a/src/routes/viewer/[country]/[place]/[photo].svelte
+++ b/src/routes/viewer/[country]/[place]/[photo].svelte
@@ -39,7 +39,7 @@
pageReady,
pageTransition
} from '../../../../utils/store'
- import { getThumbnail, analyticsUpdate } from '../../../../utils/functions'
+ import { getThumbnail } from '../../../../utils/functions'
// Components
import IconGlobe from '../../../../atoms/IconGlobe'
@@ -59,32 +59,22 @@
const { page } = stores()
const dispatch = createEventDispatcher()
let windowWidth
+ let gotoLink
let currentPhoto = photos.find(photo => photo.slug === $page.params.photo)
// Update store current location
if (!$currentLocation) currentLocation.set($locations.find(loc => loc.slug === $page.params.place))
if (!$currentPhotos) currentPhotos.set(photos)
- // Photo has changed from the Carousel component
+ // Photo has changed (from Carousel)
const photoChanged = event => {
- currentPhoto = event.detail.currentPhoto
-
- // Change the URL to the current photo
- if (!event.detail.init) {
- const windowPathname = window.location.pathname
- const newUrl = windowPathname.substring(0, windowPathname.lastIndexOf('/') + 1) + currentPhoto.slug
- history.pushState('', document.title, newUrl)
- analyticsUpdate(newUrl)
- }
+ const windowPathname = window.location.pathname
+ const newUrl = windowPathname.substring(0, windowPathname.lastIndexOf('/') + 1) + event.detail.slug
+ // Go to page via a sapper-noscroll link to avoid scroll jump
+ gotoLink.href = newUrl
+ gotoLink.click()
}
- // Access a direct photo or navigate in history
- const photoSlug = $page.params.photo
- // On init, send an event to the Carousel component with the photoSlug to set currentIndex and then change the photo
-
- // Pop event from browser (prev/next)
- const changedUrl = event => dispatch('changedUrl', { currentPhoto: currentPhoto })
-
/*
** Run code when mounted
@@ -92,8 +82,6 @@
onMount(() => {
// Page is loaded
pageReady.set(true)
-
- dispatch('changeUrl', { page: $page })
})
@@ -129,12 +117,12 @@