Skip to content

Commit

Permalink
fix: prevent Nav flickering on mobile (#164)
Browse files Browse the repository at this point in the history
Firefox for Android occasionally emits multiple scroll events with the
same `scrollTop` integer value towards the end of an inertia scroll,
which causes the Nav to flicker between visible states. This fixes it by
keeping the visible state the same if `scrollTop` is unchanged.
  • Loading branch information
zqianem committed Jul 15, 2023
1 parent 202903c commit 1462fbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/yellow-islands-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/site-kit': patch
---

Fix nav flickering on mobile
4 changes: 3 additions & 1 deletion packages/site-kit/src/lib/nav/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ Top navigation bar for the application. It provides a slot for the left side, th
const scroll = root_scroll_element.scrollTop;
if (!hash_changed) {
visible = scroll < 50 || scroll < last_scroll;
visible = scroll === last_scroll
? visible
: scroll < 50 || scroll < last_scroll;
}
last_scroll = scroll;
Expand Down

0 comments on commit 1462fbe

Please sign in to comment.