aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/LandingHero.svelte4
-rw-r--r--src/routes/+layout.svelte5
-rw-r--r--src/stores/lenis.ts6
3 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/LandingHero.svelte b/src/lib/LandingHero.svelte
index b57aec85..9f5d0368 100644
--- a/src/lib/LandingHero.svelte
+++ b/src/lib/LandingHero.svelte
@@ -1,6 +1,7 @@
<script lang="ts">
import { env } from "$env/dynamic/public";
import localforage from "localforage";
+import lenis from "$stores/lenis";
let heroSection = $state<HTMLElement>();
@@ -10,7 +11,8 @@ const scrollPastHero = () => {
const heroBottom =
heroSection.getBoundingClientRect().bottom + window.scrollY;
- window.scrollTo({ top: heroBottom, behavior: "smooth" });
+ if ($lenis) $lenis.scrollTo(heroBottom);
+ else window.scrollTo({ top: heroBottom, behavior: "smooth" });
};
</script>
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 7f962884..fa0f4a25 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -41,6 +41,7 @@ import { dev } from "$app/environment";
import { injectAnalytics } from "@vercel/analytics/sveltekit";
import Lenis from "lenis";
import "lenis/dist/lenis.css";
+import lenisStore from "$stores/lenis";
import type { LayoutData } from "./$types";
injectSpeedInsights();
@@ -99,6 +100,8 @@ onMount(async () => {
if (browser) {
lenis = new Lenis({ autoRaf: true });
+ lenisStore.set(lenis);
+
if (await localforage.getItem("redirect")) {
window.location.href = (await localforage.getItem("redirect")) ?? "/";
@@ -169,6 +172,8 @@ onDestroy(() => {
if (notificationInterval) clearInterval(notificationInterval);
lenis?.destroy();
+
+ lenisStore.set(undefined);
});
$: {
diff --git a/src/stores/lenis.ts b/src/stores/lenis.ts
new file mode 100644
index 00000000..a0f028b5
--- /dev/null
+++ b/src/stores/lenis.ts
@@ -0,0 +1,6 @@
+import type Lenis from "lenis";
+import { writable } from "svelte/store";
+
+const lenis = writable<Lenis | undefined>(undefined);
+
+export default lenis;