Skip to content

Commit 6e6fc57

Browse files
committed
Remove unnecessary context use
1 parent c7c4672 commit 6e6fc57

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

src/lib/page-transition.js

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
import { afterNavigate, beforeNavigate } from '$app/navigation';
2-
import { setContext, getContext, hasContext, onDestroy } from 'svelte';
2+
import { onDestroy } from 'svelte';
33
import { writable } from 'svelte/store';
44
import reducedMotion from './reduced-motion';
55

6-
const contextKey = 'transition';
7-
8-
export function initTransitionContext() {
9-
if (hasContext(contextKey)) return getContext(contextKey);
10-
return setContext(contextKey, writable({}));
11-
}
12-
13-
function getTransitionContext() {
14-
if (!hasContext(contextKey)) {
15-
return initTransitionContext();
16-
}
17-
return getContext(contextKey);
18-
}
19-
206
export const preparePageTransition = () => {
21-
const transitionStore = getTransitionContext();
7+
const transitionStore = writable({});
228
let unsub;
239
let isReducedMotionEnabled;
2410

src/routes/__layout.svelte

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import '../app.css';
33
import Navbar from '$lib/Navbar.svelte';
44
import Footer from '$lib/Footer.svelte';
5-
import { initTransitionContext, preparePageTransition } from '$lib/page-transition';
5+
import { preparePageTransition } from '$lib/page-transition';
66
7-
initTransitionContext();
87
preparePageTransition();
98
</script>
109

0 commit comments

Comments
 (0)