jQuery noConflict的2个不同功能的问题

时间:2018-12-02 17:18:43

标签: javascript jquery

任何人都可以指导我为以下两个不同的函数编写Jquery noConflict吗?一个功能用于粘贴标题,另一功能用于搜索弹出窗口。

标题:-

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 sure they scroll more than delta
    if(Math.abs(lastScrollTop - st) <= delta)
        return;

    // If they scrolled down and are past the navbar, add class .nav-up.
    // This is necessary so you never see what is "behind" the navbar.
    if (st > lastScrollTop && st > navbarHeight){
        // Scroll Down
        $('.header').removeClass('nav-down').addClass('nav-up');
    } else {
        // Scroll Up
        if(st + $(window).height() < $(document).height()) {
            $('.header').removeClass('nav-up').addClass('nav-down');

        }
    }

    lastScrollTop = st;
}

搜索:-

function openSearch() {
      $("#myOverlay").fadeIn(); // "500" is not required. "400" is the default value
  }

  function closeSearch() {
      $("#myOverlay").fadeOut();  // "500" is not required. ""400 is the default value
  }

0 个答案:

没有答案