Viewer: Finally fix Carousel navigation depending on URL

- Instead of detecting every case using popState event or whatnot, used a Sapper page stores subscribe to go to the current photo from the URL param (findIndex in photos)
- No page transition when navigating between photos in Viewer, but runs In and Out
- Also shortened dispatches to direct value over an object
This commit is contained in:
2020-03-29 18:13:27 +02:00
parent 25fa9e1c07
commit ca07fe364e
6 changed files with 73 additions and 81 deletions

View File

@@ -22,18 +22,28 @@
*/
let scope
let firstLoad = true
let previousPage = ''
// Check if viewer
const isExcluded = path => path.includes(['/viewer/'])
// 1. Watch page change
page.subscribe(page => {
// Run the loader animation (only after first load)
if (!firstLoad) {
animateIn(scope)
// Run transition if page is not excluded
if (!isExcluded(previousPage) || !isExcluded(page.path)) {
// Run the loader animation (only after first load)
if (!firstLoad) {
animateIn(scope)
}
// TODO: Figure out how to delay the page rendering a little bit before the end of the transition panel ending
// Set pageReady to false (?)
pageReady.set(false)
}
// TODO: Figure out how to delay the page rendering a little bit before the end of the transition panel ending
// Set pageReady to false (?)
pageReady.set(false)
// Update page for viewer navigation checking
previousPage = page.path
})
// 2. Watch when loaded changes