Created
May 26, 2021 14:40
-
-
Save design-innovations/88c5c4a4dfffdf0284c9347606c2049a to your computer and use it in GitHub Desktop.
Alpine - Scroll detection - fixed header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div x-data="{ scrollAtTop: true }"> | |
<nav | |
class="p-4 w-full fixed" | |
:class="{ 'bg-white shadow-md' : !scrollAtTop }" | |
@scroll.window="scrollAtTop = (window.pageYOffset > 50) ? false : true" | |
> | |
Header - Menu Bar | |
</nav> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment