Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // When the user scrolls the page, execute myFunction
- window.onscroll = function() {scrollFunction()};
- // Get the header ID class + Logo class
- var header = document.getElementById("headbrand");
- var header2 = document.getElementById("header");
- // Get the offset position of the navbar
- var sticky = header.offsetTop;
- // Add the sticky and headbrand class to the header and logo when you reach its scroll position. Remove "sticky" and restore logo size when you leave the scroll position
- function scrollFunction() {
- if (window.pageYOffset >= sticky) {
- header.classList.add('headlogo','img'); header2.classList.add("sticky");
- } else {
- header.classList.remove('headlogo','img'); header2.classList.remove("sticky");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement