Hello everybody !
I followed this tutorial :
it works, no problem but i’m only looking when i scroll up, possible ?
thx !
Hello everybody !
I followed this tutorial :
it works, no problem but i’m only looking when i scroll up, possible ?
thx !
Welcome to the Shopify community!
and Thanks for your question.
Please share your site URL,
So I will check and provide a solution here.
Thanks please flow this step
$(window).scroll(function() {
if ($(this).scrollTop() > 35){
$('.site-header').addClass("sticky");
}
else{
$('.site-header').removeClass("sticky");
}
});
Step = 2
.site-header.sticky {
position: fixed;
width: 100%;
z-index: 1;
top: 0;
}
thx @KetanKumar
it works, but i’m looking only for it to work when I scroll up and not when I scroll down
yes, i think @KetanKumar
where to insert the code for htlm ?
not just HTML code
but can you try this script may work
remove first-script after this add
// Hide header on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('header').outerHeight();
$(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
function hasScrolled() {
var st = $(this).scrollTop();
// Make scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If scrolled down and past the navbar, add class .nav-up.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
$('header').removeClass('site-header').addClass('nav-up');
} else {
// Scroll Up
if(st + $(window).height() < $(document).height()) {
$('header').removeClass('nav-up').addClass('site-header');
}
}
lastScrollTop = st;
}
I replaced theme.js with the last one but it doesn’t work .
just my logo and shopping cart logo, customer logo and search logo just moving when scroll up.
to give you an idea, here is an store exemple when scroll up.
It can be done by doing some code customization. please send me a personal message and we can discuss what you’d like
@KetanKumar it work sorry, i’m an idiot !
but in collection page have a bug
We have checked for this issue in real system and browserstack but it is working ok. In which system configuration or browser you are checking?
Where should we put this code, can you tell us the location of the code?
are you able to shopify liquid code otherwise please don’t try it your can assign someone else or ,me
Hello @KetanKumar ,
I followed this guide for creating a sticky header and I chose Option 2: STICKY HEADER WITHOUT THE ANNOUNCEMENT BAR. I would like to have the announcement bar in the whole site but have it fade out when scrolling up. But, I face 2 issues in the process:
I wish to make it like this site. Most grateful for your advice, please. Thanks!
Leatheraholicx