https://github.com/andrewjbateman/javascript-scroll-navbar
:clipboard: Uses css to add a class to change the nav bar when the user scrolls up. Wes Bos Javascript30 tutorial 24
https://github.com/andrewjbateman/javascript-scroll-navbar
css3 html5 javascript30 tutorial-code
Last synced: 3 months ago
JSON representation
:clipboard: Uses css to add a class to change the nav bar when the user scrolls up. Wes Bos Javascript30 tutorial 24
- Host: GitHub
- URL: https://github.com/andrewjbateman/javascript-scroll-navbar
- Owner: AndrewJBateman
- Created: 2018-12-10T10:36:41.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-05T07:53:17.000Z (almost 4 years ago)
- Last Synced: 2024-12-27T02:44:57.687Z (about 1 year ago)
- Topics: css3, html5, javascript30, tutorial-code
- Language: HTML
- Homepage:
- Size: 2.83 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# :zap: Javascript Scroll Navbar
* Wes Bos Youtube Tutorial: [Vanilla JavaScript Sticky Nav - #JavaScript30 24/30](https://www.youtube.com/watch?v=5FLOBCGH3_U&list=PLu8EoSxDXHP6CGK4YVJhL_VWetA865GOH&index=24).
* **Note:** to open web links in a new window use: _ctrl+click on link_




## :page_facing_up: Table of contents
* [:zap: Javascript Scroll Navbar](#zap-javascript-scroll-navbar)
* [:page_facing_up: Table of contents](#page_facing_up-table-of-contents)
* [:books: General info](#books-general-info)
* [:camera: Screenshots](#camera-screenshots)
* [:signal_strength: Technologies](#signal_strength-technologies)
* [:floppy_disk: Setup](#floppy_disk-setup)
* [:computer: Code Examples](#computer-code-examples)
* [:cool: Features](#cool-features)
* [:clipboard: Status & To-Do List](#clipboard-status--to-do-list)
* [:clap: Inspiration](#clap-inspiration)
* [:file_folder: License](#file_folder-license)
* [:envelope: Contact](#envelope-contact)
## :books: General info
* Tutorial Code to add a class to change the nav bar when the user scrolls. Also changes the width of the text div.
## :camera: Screenshots
.
## :signal_strength: Technologies
* [Javascript v1.9 ECMA-262 ECMAScript 2018](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
## :floppy_disk: Setup
* Open `index.html` in browser. If any code is changed the browser needs to be refreshed.
## :computer: Code Examples
* compares scroll position with top of Navigation and adds the 'fixed-nav' class when they are equal.
```javascript
fixNav = () => {
console.log('window.scrollY', window.scrollY, 'topOfNav', topOfNav);
if(window.scrollY >= topOfNav) {
console.info('window.scrollY >= topOfNav');
document.body.style.paddingTop = nav.offsetHeight + 'px';
document.body.classList.add('fixed-nav');
} else {
document.body.style.paddingTop = 0;
document.body.classList.remove('fixed-nav');
}
}
```
## :cool: Features
* At about scrollY = 337px the css class change occurs to 'fixed-nav'.
## :clipboard: Status & To-Do List
* Status: Working.
* To-Do: Nothing
## :clap: Inspiration
* Wes Bos Youtube Tutorial: [Vanilla JavaScript Sticky Nav - #JavaScript30 24/30](https://www.youtube.com/watch?v=5FLOBCGH3_U&list=PLu8EoSxDXHP6CGK4YVJhL_VWetA865GOH&index=24)
## :file_folder: License
* N/A
## :envelope: Contact
* Repo created by [ABateman](https://github.com/AndrewJBateman), email: gomezbateman@yahoo.com