Skip to content

Commit 7781bfd

Browse files
committed
feat: Improve visibility check logic and styling
1 parent 393d2d6 commit 7781bfd

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/routes/+page.svelte

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,13 @@
77
88
let bottomVisibility = true;
99
10-
onMount(() => {
11-
const checkVisibility = () => {
12-
const wave = document.querySelector('.wave');
13-
bottomVisibility = !(wave && wave.getBoundingClientRect().bottom < window.innerHeight - 1);
14-
};
15-
16-
window.addEventListener('scroll', checkVisibility, { passive: true });
17-
window.addEventListener('resize', checkVisibility);
10+
const checkVisibility = () => {
11+
const wave = document.querySelector('.wave');
12+
bottomVisibility = !(wave && wave.getBoundingClientRect().bottom < window.innerHeight - 1);
13+
};
1814
15+
onMount(() => {
1916
checkVisibility(); // Initial check
20-
return () => {
21-
window.removeEventListener('scroll', checkVisibility);
22-
window.removeEventListener('resize', checkVisibility);
23-
};
2417
});
2518
</script>
2619

@@ -135,7 +128,9 @@
135128
]}
136129
/>
137130

138-
<main>
131+
<svelte:window on:scroll={checkVisibility} on:resize={checkVisibility} />
132+
133+
<main class:visibility={!bottomVisibility}>
139134
<div class="content">
140135
<Home socialsVisibility={bottomVisibility} />
141136
<div class="hero-img-container">
@@ -161,10 +156,17 @@
161156
flex-direction: column;
162157
align-items: center;
163158
159+
@media (max-height: 600px), (max-width: 450px) and (max-height: 780px) {
160+
min-height: initial;
161+
}
162+
164163
@media (max-width: 335px) {
165164
padding: 2rem 0 !important;
166165
}
167166
167+
&.visibility {
168+
min-height: initial;
169+
}
168170
}
169171
170172
.hero-img-container {

0 commit comments

Comments
 (0)