当特定部分在屏幕上时的toggleClass
这个问题在这里已经有了答案:
  你想要做的是添加类,如果scroll +你的h3的偏移量大于该部分的偏移量,并且如果scroll +你的h3的偏移量大于该部分的偏移量+它的高度,则将其删除。 
看看这个:https://jsfiddle.net/Lp27vuu4/4/
Waypoints是触发滚动事件的流行插件。
http://imakewebthings.com/waypoints/
将航点js文件放在您的项目中并链接到它。 然后在你的jQuery文件中做下面的事情
        function toggleClassFunction() {
            $('nav').toggleClass('light-mode');
        }
        var waypoint = new Waypoint({
        element: document.getElementById('id-of-element-when-scrolled-to-event-triggers'),
        handler: function(direction) {
            if (direction === 'down') {
                toggleClassFunction(); // the function that runs
                this.destroy() //runs the function once
            }
            else {
            }
        },
        offset: 250 //since the event triggers once the element reaches the top of the page, we
                    //sometimes need an offset. so in this example, when the element is 250px from
                    //the top of the page, the even triggers
        });
                        链接地址: http://www.djcxy.com/p/83337.html
                        
                        
                    