Javascript 滚动功能冲突,导致链接点击延迟

Javascript 滚动功能冲突,导致链接点击延迟,javascript,jquery,html,function,Javascript,Jquery,Html,Function,我有两个函数用于两种不同的东西 首先,我得到了页面上锚链接的平滑滚动 $(window).on("load",function () { // bind click event to all internal page anchors $('a[href*="#"]').on('click', function (e) { // prevent default action and bubbling

我有两个函数用于两种不同的东西

首先,我得到了页面上锚链接的平滑滚动

$(window).on("load",function () {
        // bind click event to all internal page anchors
        $('a[href*="#"]').on('click', function (e) {
                // prevent default action and bubbling
                e.preventDefault();
                e.stopPropagation();
                // set target to anchor's "href" attribute
                var target = $(this).attr('href');
                // scroll to each target
                $(target).velocity('scroll', {
                        duration: 700,
                        offset: -50,
                        easing: 'ease',
                });
        });
});
另一个是当您滚动到内容时,内容中的淡入淡出

// fade all the sections
$(window).on("load",function() {
  $(window).scroll(function() {
    var currentPos = $(this).scrollTop()
    $(".section").each(function() {
            var topPos = $(this).offset().top - 500,
                    bottomPos = topPos + $(this).outerHeight();

      /* If the element is completely within bounds of the window, fade it in */
      if (currentPos >= topPos && currentPos <= bottomPos) { //object comes into view (scrolling down)
        $(this).fadeTo(700,1);
      }
    });
  }) //invoke scroll-handler on page-load
});
//淡出所有部分
$(窗口).on(“加载”,函数(){
$(窗口)。滚动(函数(){
var currentPos=$(this).scrollTop()
$(“.section”)。每个(函数(){
var topPos=$(this).offset().top-500,
bottomPos=topPos+$(this).outerHeight();
/*如果元素完全在窗口边界内,则淡入*/
如果(currentPos>=topPos&¤tPos解决方案:

使用css代替Jquery进行淡入