Adding comments for Photos page's filters handling issue

This commit is contained in:
2021-11-21 13:40:52 +01:00
parent 68236bf39e
commit 1a48d408ab
2 changed files with 15 additions and 5 deletions

View File

@@ -35,8 +35,12 @@
// Scroll back to top between page transitions // Scroll back to top between page transitions
setTimeout(() => { setTimeout(() => {
// scrollToTop() // scrollToTop()
// Disable scroll when changing filters on /photos?
if (!$page.query.get('country')) {
window.scrollTo(0,0) window.scrollTo(0,0)
}, DURATION.PAGE_OUT) }
}, DURATION.PAGE_OUT * 1.5)
} }
}) })

View File

@@ -89,7 +89,12 @@
urlFiltersParams.set('country', filterCountry) urlFiltersParams.set('country', filterCountry)
urlFiltersParams.set('sort', filterSort) urlFiltersParams.set('sort', filterSort)
let path: string = `${$page.path}?${urlFiltersParams.toString()}` let path = `${$page.path}?${urlFiltersParams.toString()}`
console.log(path)
// TODO: Load new params properly?
// 1. How to properly navigate to new page / 2. Avoid scrolling to top (from global __layout)
// Feels like it calls the url multiple times
goto(path, { replaceState: true, keepfocus: true, noscroll: true }) goto(path, { replaceState: true, keepfocus: true, noscroll: true })
} }
@@ -245,7 +250,7 @@
}) })
}, { }, {
threshold: 0.3, threshold: 0.3,
rootMargin: '0px 0px 0px' rootMargin: '0px 0px 10%'
}) })
// Photos MutationObserver // Photos MutationObserver
@@ -269,6 +274,7 @@
// Destroy // Destroy
return () => { return () => {
// Disconnect observers
observerPhotos && observerPhotos.disconnect() observerPhotos && observerPhotos.disconnect()
mutationPhotos && mutationPhotos.disconnect() mutationPhotos && mutationPhotos.disconnect()
} }