Don't scroll back to top when changing Photos and Shop products pages
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import { navigating, page } from '$app/stores'
|
import { navigating, page } from '$app/stores'
|
||||||
import { onMount, setContext } from 'svelte'
|
import { onMount, setContext } from 'svelte'
|
||||||
import { pageLoading } from '$utils/stores'
|
import { pageLoading } from '$utils/stores'
|
||||||
|
import { scrollToTop } from '$utils/functions'
|
||||||
import { DURATION } from '$utils/contants'
|
import { DURATION } from '$utils/contants'
|
||||||
import '$utils/polyfills'
|
import '$utils/polyfills'
|
||||||
// Components
|
// Components
|
||||||
@@ -34,12 +35,10 @@
|
|||||||
|
|
||||||
// Scroll back to top between page transitions
|
// Scroll back to top between page transitions
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// scrollToTop()
|
// Disable scroll when changing filters on /photos and shop?
|
||||||
// Disable scroll when changing filters on /photos?
|
if (!$page.query.get('country') && !$page.path.includes('/shop/poster')) {
|
||||||
if (!$page.query.get('country')) {
|
scrollToTop()
|
||||||
window.scrollTo(0,0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, DURATION.PAGE_OUT * 1.5)
|
}, DURATION.PAGE_OUT * 1.5)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -118,3 +118,17 @@ export const getPosition = (node, scope?: HTMLElement) => {
|
|||||||
left: offsetLeft
|
left: offsetLeft
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scroll back to top after page transition
|
||||||
|
*/
|
||||||
|
export const scrollToTop = (delay?: number) => {
|
||||||
|
const scroll = () => window.scrollTo(0,0)
|
||||||
|
|
||||||
|
if (delay && delay > 0) {
|
||||||
|
setTimeout(scroll, delay)
|
||||||
|
} else {
|
||||||
|
scroll()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user