Created
August 5, 2019 00:11
-
-
Save nikola-wd/a5f32ac0b2b02916ad8519de02ea546c to your computer and use it in GitHub Desktop.
[Fixed Header onScroll] - Header get's class when scrolled #ui #sass #scss #code_bundles #header
This file contains hidden or 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
| const _headerFN = () => { | |
| const $header = document.querySelector('.header'); | |
| const scrollTop = window.scrollY, | |
| offsetTop = 60; | |
| if (scrollTop >= offsetTop && window.innerWidth > 767) { | |
| $header.classList.add('jsOnScroll'); | |
| document.body.classList.add('jsOnScroll-header'); | |
| } else { | |
| $header.classList.remove('jsOnScroll'); | |
| document.body.classList.remove('jsOnScroll-header'); | |
| } | |
| } | |
| export default _headerFN; |
This file contains hidden or 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
| .header { | |
| &.jsOnScroll { | |
| // Add code here | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment