Skip to content

Commit b3883d2

Browse files
committed
fix: Improve socials and wave visibility condition
1 parent 098f610 commit b3883d2

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

src/lib/components/Wave.svelte

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
<svg viewBox="0 0 1440 500" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none">
1+
<script>
2+
export let bottom = 0;
3+
</script>
4+
5+
<svg
6+
viewBox="0 0 1440 500"
7+
xmlns="http://www.w3.org/2000/svg"
8+
preserveAspectRatio="none"
9+
style="bottom: {-bottom}; height: {bottom / 5 + 35}vh"
10+
>
211
<path class="wave" />
312
</svg>
413

514
<style>
615
svg {
16+
transition: height 1s var(--bezier-one);
717
position: absolute;
818
z-index: -999;
9-
bottom: 0;
10-
height: 35vh;
1119
width: 100%;
1220
}
1321

src/routes/+page.svelte

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,33 @@
55
import Wave from '$lib/components/Wave.svelte';
66
import Footer from '$layout/Footer/FooterHost.svelte';
77
import Head from '$lib/components/Head.svelte';
8+
import { onMount } from 'svelte';
89
910
let scrollY = 0;
1011
let footerVisible = false;
1112
12-
$: footerVisible = scrollY >= 10;
13+
// temporary fix until rewrite is out
14+
function checkVisibility() {
15+
if (scrollY === 0) return (footerVisible = false);
16+
17+
const el = document.querySelector('#skiptab > main > div.hide-on-scroll.s-y_bCXRrkrYfP > div');
18+
const buffer = 24; // 1.5rem gap
19+
20+
if (!el) return (footerVisible = scrollY >= 24);
21+
22+
const rect = el.getBoundingClientRect();
23+
footerVisible = rect.bottom + buffer <= window.innerHeight;
24+
}
25+
26+
onMount(() => {
27+
window.addEventListener('scroll', checkVisibility, { passive: true });
28+
window.addEventListener('resize', checkVisibility);
29+
30+
return () => {
31+
window.removeEventListener('scroll', checkVisibility);
32+
window.removeEventListener('resize', checkVisibility);
33+
};
34+
});
1335
</script>
1436

1537
<svelte:window bind:scrollY />
@@ -133,7 +155,7 @@
133155
</div>
134156
</div>
135157
<div class="hide-on-scroll" class:hidden={footerVisible}>
136-
<Wave />
158+
<Wave bottom={scrollY} />
137159
<SocialHost />
138160
</div>
139161
</main>

0 commit comments

Comments
 (0)