Javascript 是否在向下滚动时触发fullpage.js事件?

Javascript 是否在向下滚动时触发fullpage.js事件?,javascript,jquery,fullpage.js,Javascript,Jquery,Fullpage.js,我想在用户向下滚动并更改部分时触发 我想做一些像这样的事情: $(document).ready(function () { /* * /* SCROLL Event /* */ $(window).scroll(function () { document.getElementById("navbar").style.background = "rgba(0, 0, 0, 0.2)"; $(".logo a").css("color", "#ec008c");

我想在用户向下滚动并更改部分时触发

我想做一些像这样的事情:

$(document).ready(function () {

/* *
/* SCROLL Event
/* */
$(window).scroll(function () {
        document.getElementById("navbar").style.background = "rgba(0, 0, 0, 0.2)";
        $(".logo a").css("color", "#ec008c");
        $(".box-shadow-menu").css("background-color", "#ec008c");
        $(".box-shadow-menu").css("box-shadow", "0 0.37em 0 0 #ec008c, 0 0.73em 0 0 #ec008c");
        console.log("Scroll")
    });
});
我该怎么办? 如果我使用的代码不起作用,为什么

谢谢,,
吉安·马可。

是在窗口没有地方向右滚动的情况下

我想你得把鼠标轮事件绑起来

   $(window).bind('mousewheel', function(e){
     if(e.originalEvent.wheelDelta /120 > 0) {
       console.log('scrolling up');
     }
     else{
       console.log('scrolling down');
     }
   });
但我认为您可能需要触发fullpage.js或。 您可能应该在离开第一张(或其他)幻灯片时触发JS更改颜色,例如:

    $('#fullpage').fullpage({
    onLeave: function(index, nextIndex, direction){
        var leavingSection = $(this);

        //after leaving section 1
        if(index == 1 && direction =='down'){
            document.getElementById("navbar").style.background = "rgba(0, 0, 0, 0.2)";
            $(".logo a").css("color", "#ec008c");
            $(".box-shadow-menu").css("background-color", "#ec008c");
            $(".box-shadow-menu").css("box-shadow", "0 0.37em 0 0 #ec008c, 0 0.73em 0 0 #ec008c");       
        }          
    }
});

有关的文档

请使用@s3rila建议的或。查看有关state类的回调演示和视频教程。但是@Alvaro没有startscroll回调。OnLeave与此不同。当对内容太多而无法放入fullpage节中的内容节使用fullpage.js,因此需要向下滚动时,无法使用OnLeave在某个滚动位置触发所需的操作,因为在调用事件时,您尚未离开节。举个例子,我们在向下滚动时隐藏固定标题的某些方面,以便它不会与内容重叠。我们不能使用onLeave来实现这一点。我们必须监视滚动。