简体   繁体   English

Opencart主题中的Javascript滚动问题

[英]Javascript scroll issue in Opencart theme

I'm working on a project based on Opencart with the theme Tranda Social (I think it's deprecated). 我正在一个基于Opencart的项目,主题为Tranda Social(我认为已弃用)。 The problem I'm facing is that at Home page ONLY I can't get the scroll-effects (eg. When scrolling-down keep the navbar in fixed position, or getting to the TOP by just clicking the button with the UP-arrow). 我面临的问题是,仅在主页上我无法获得滚动效果(例如,向下滚动时,将导航栏保持在固定位置,或者仅通过单击带有向上箭头的按钮进入顶部)。 After some research I've concluded that for some reason a Javascript function isn't get called correctly. 经过研究,我得出结论,由于某种原因,无法正确调用Javascript函数。

setTimeout(function () {

    /* Menu */
    $('#menu ul > li > a + div').each(function (index, element) {

        var menu = $('#menu').offset();
        var dropdown = $(this).parent().offset();
        i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth());
        if (i > 0) {
            $(this).css('margin-left', '-' + (i + 5) + 'px');
        }
    });

    /* Fixed Menu */
    $(function () {

        var msie6 = $.browser == 'msie' && $.browser.version < 7;
        if (!msie6) {
            var top = $('#bottomh').offset().top;
            $(window).scroll(function (event) {
                var y = $(this).scrollTop();
                if (y >= top) {
                    $('#bottomh').addClass('bottomfixed');
                } else {
                    $('#bottomh').removeClass('bottomfixed');
                }
            });
        }
    });

    $(function () {

        var msie6 = $.browser == 'msie' && $.browser.version < 7;
        if (!msie6) {
            var top = $('#bottomh').offset().top;
            $(window).scroll(function (event) {
                var y = $(this).scrollTop();
                if (y >= top) {
                    $('#bottomh').addClass('bottomfixed');
                } else {
                    $('#bottomh').removeClass('bottomfixed');
                }
            });
        }
    });

    /* Margin Menu */
    $(function () {

        var msie6 = $.browser == 'msie' && $.browser.version < 7;
        if (!msie6) {
            var top = $('#bottomh').offset().top;
            $(window).scroll(function (event) {
                var y = $(this).scrollTop();
                if (y >= top) {
                    $('#container').addClass(' topmargin');
                } else {
                    $('#container').removeClass(' topmargin');
                }
            });
        }
    });

    $(function () {
        var msie6 = $.browser == 'msie' && $.browser.version < 7;
        if (!msie6) {
            var top = $('#bottomh').offset().top;
            $(window).scroll(function (event) {
                var y = $(this).scrollTop();
                if (y >= top) {
                    $('#container').addClass(' topmargin');
                } else {
                    $('#container').removeClass(' topmargin');
                }
            });
        }
    });
}, 500);

The functions after fixed-menu and margin-menu comments are NOT working when I'm navigating in Home page. 当我在主页中导航时,固定菜单和边距菜单注释后的功能不起作用。 Also if you notice, there is a duplicate of each function (don't know for what reason). 另外,如果您注意到,每个功能都有一个重复项(不知道是出于什么原因)。 Have you any ideas? 你有什么想法吗? Any help will be greatly appreciated. 任何帮助将不胜感激。

It was a problem caused by Slidesshow module (Nivo Slider) because of a JS error related to it. 这是由Slidesshow模块(Nivo Slider)引起的,因为与之相关的JS错误。 Uninstall-reinstall the module fixes the problem. 卸载然后重新安装模块即可解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM