Store previous page for photo Viewer close button
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
import { scale } from 'svelte/transition'
|
import { scale } from 'svelte/transition'
|
||||||
import { quartOut } from 'svelte/easing'
|
import { quartOut } from 'svelte/easing'
|
||||||
import { getAssetUrlKey } from '$utils/helpers'
|
import { getAssetUrlKey } from '$utils/helpers'
|
||||||
|
import { previousPage } from '$utils/stores'
|
||||||
import { throttle } from '$utils/functions'
|
import { throttle } from '$utils/functions'
|
||||||
import { swipe } from '$utils/interactions/swipe'
|
import { swipe } from '$utils/interactions/swipe'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
@@ -220,7 +221,7 @@
|
|||||||
|
|
||||||
<ButtonCircle
|
<ButtonCircle
|
||||||
tag="a"
|
tag="a"
|
||||||
url="/{location.country.slug}/{location.slug}"
|
url={$previousPage ? $previousPage : `/${location.country.slug}/${location.slug}`}
|
||||||
color="purple"
|
color="purple"
|
||||||
class="viewer-photo__close shadow-box-dark"
|
class="viewer-photo__close shadow-box-dark"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import '../style/style.scss'
|
import '../style/style.scss'
|
||||||
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, previousPage } from '$utils/stores'
|
||||||
import { scrollToTop } from '$utils/functions'
|
import { scrollToTop } from '$utils/functions'
|
||||||
import { DURATION } from '$utils/contants'
|
import { DURATION } from '$utils/contants'
|
||||||
import '$utils/polyfills'
|
import '$utils/polyfills'
|
||||||
@@ -24,6 +24,14 @@
|
|||||||
/**
|
/**
|
||||||
* On page change
|
* On page change
|
||||||
*/
|
*/
|
||||||
|
// Store previous page (for photo Viewer close button)
|
||||||
|
let previous = ''
|
||||||
|
page.subscribe(value => {
|
||||||
|
$previousPage = previous
|
||||||
|
previous = value.path
|
||||||
|
})
|
||||||
|
|
||||||
|
// Define page loading from navigating store
|
||||||
navigating.subscribe((store: any) => {
|
navigating.subscribe((store: any) => {
|
||||||
if (store) {
|
if (store) {
|
||||||
$pageLoading = true
|
$pageLoading = true
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
|
|
||||||
export const pageLoading = writable(false)
|
export const pageLoading = writable(false)
|
||||||
|
export const previousPage = writable('')
|
||||||
Reference in New Issue
Block a user