Jump to content

Sticky navigation issue


Vali Iacobescu

Recommended Posts

Hello,

Prestashop 1.6.1.0
Theme: warehouse

I have a problem with a sticky horizontal navigation bar.

My home page has a big image in header and my sticky navbar sometimes jumps on top of page before supposed to stick when I begin to scroll. I have this problem only on homepage where is this big image on header. On all the other pages, sticky navbar it behaves normally.

I have this issue only in Firefox. This is the site: https://scufita-rosie.ro Please, help! Thanks!

This is the code for sticky navbar:

var isStickMenu = true;

$(document).ready(function() {
if (typeof iqit_inlineh != 'undefined') {
    var s = $("#header");
    var pos = s.offset();
    var alreadySticky = false;

    $(window).scroll(function() {
        var windowpos = $(window).scrollTop();
        if (s.length) {
            if (!alreadySticky) {
                if (windowpos > pos.top + 200) {
                    alreadySticky = true;
                    if ($('#header').width() >= 985)
                        $('#page').css('margin-top', s.height());
                    s.addClass("sticky-header");
                }
            }
            if (alreadySticky) {
                if (windowpos <= pos.top) {
                    alreadySticky = false;
                    $('#page').removeAttr("style");
                    s.removeClass("sticky-header");
                }
            }
        }
    });
} else {
    var s = $("#iqitmegamenu-horizontal");
    var pos = s.offset();
    var scartp = (s.outerHeight() / 2) - 13;
    var alreadySticky = false;
    var scart = $("#shopping_cart_container");

    $(window).scroll(function() {
        var windowpos = $(window).scrollTop();
        if (s.length) {
            if (!alreadySticky) {
                if (windowpos >= pos.top) {
                    alreadySticky = true;
                    s.parent().height(s.height());
                    s.addClass("cbp-sticky");
                    scart.addClass("stickCart");
                    scart.css({
                        top: scartp + 'px'
                    });
                }
            }
            if (alreadySticky) {
                if (windowpos < pos.top) {
                    alreadySticky = false;
                    s.removeClass("cbp-sticky");
                    scart.removeClass("stickCart");
                    scart.removeAttr("style");
                    s.parent().removeAttr("style");
                }
            }
         }
     });
   }
});
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...