Tibetan | Software Engineer | Application Dev
Sticky header fix js
Sticky header fix js

Sticky header fix js

var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
// document.querySelector(“#cb-row–header-main > div”).style.height = “120px”
document.querySelector(“#cb-row–header-main > div”).style.transition = “250ms”
document.querySelector(“#cb-row–header-main”).style.transition = “250ms”
document.querySelector(“.header–row.header-main .customify-grid, .header–row.header-main .style-full-height .primary-menu-ul > li > a”).style.transition = “250ms”

if(window.scrollY < 50 ){
document.querySelector(“#cb-row–header-main > div”).style.minHeight = “120px”
document.querySelector(“.header–row.header-main .customify-grid, .header–row.header-main .style-full-height .primary-menu-ul > li > a”).style.minHeight =”120px”
} else {
document.querySelector(“#cb-row–header-main > div”).style.minHeight = “80px”
document.querySelector(“.header–row.header-main .customify-grid, .header–row.header-main .style-full-height .primary-menu-ul > li > a”).style.minHeight =”80px”
}
// console.log(“Prev: ” + prevScrollpos)
// console.log(“Current: ” + currentScrollPos)

// if (prevScrollpos > currentScrollPos) {
// //going up
// // document.getElementById(‘cb-row–header-main’).style.display= “block”;

// document.getElementById(‘cb-row–header-main’).style.opacity= “1”;
// document.getElementById(‘cb-row–header-main’).style.visibility= “visible”;
// document.querySelector(“#cb-row–header-main > div”).style.height = “120px”

// } else {
// //going down
// if(currentScrollPos > 120) {
// document.querySelector(“#cb-row–header-main > div”).style.height = “80px”
// document.getElementById(‘cb-row–header-main’).style.opacity= “1”;
// // document.getElementById(‘cb-row–header-main’).style.visibility= “hidden”;
// // document.getElementById(‘cb-row–header-main’).style.display= “none”;
// }

// }
prevScrollpos = currentScrollPos ;

Leave a Reply

Your email address will not be published. Required fields are marked *

0
    0
    Your Cart
    Your cart is emptyReturn to Shop
      Calculate Shipping
      Apply Coupon