Jquery plugins 重复滚动间谍

Jquery plugins 重复滚动间谍,jquery-plugins,Jquery Plugins,我用了一个jQueryScrollSpy(https://github.com/sxalexander/jquery-scrollspyhttps://github.com/sxalexander/jquery-scrollspy)进行设置,以便在滚动到div#red时,它各自的子项“.test”fadesIn。我如何设置它,以便当您滚动到N div的顶部时,N的子对象出现?(离开第N分区后消失) 谢谢你的帮助,我从来没有设置过这样的循环 乔 $(文档).ready(函数(){ $(“.tes

我用了一个jQueryScrollSpy(https://github.com/sxalexander/jquery-scrollspyhttps://github.com/sxalexander/jquery-scrollspy)进行设置,以便在滚动到div#red时,它各自的子项“.test”fadesIn。我如何设置它,以便当您滚动到N div的顶部时,N的子对象出现?(离开第N分区后消失)

谢谢你的帮助,我从来没有设置过这样的循环


$(文档).ready(函数(){
$(“.test”).hide();
$('#红色')。每个(功能(i){
var position=$(this.position();
控制台日志(位置);
log('min:'+position.top+'/max:'+parseInt(position.top+$(this.height());
$(此).scrollspy({
min:position.top,
max:position.top+$(此).height(),
onEnter:功能(元素、位置){
if(console)console.log('entering.#red');
$(“#红色”).children().fadeIn(200);},
onLeave:功能(元素、位置){
if(console)console.log('leaving.#red');
$(“#红色”).children().fadeOut(200);}
/*onEnter:功能(元素、位置){
if(console)console.log('entering.#blue');
$(“.test”).show();},
onLeave:功能(元素、位置){
if(console)console.log('leaving.#blue');
$(“.test”).hide();}*/
});
});
});
<script type="text/javascript">
            $(document).ready(function() {
                    $(".test").hide();

                    $('#red').each(function(i) {
                        var position = $(this).position();
                        console.log(position);
                        console.log('min: ' + position.top + ' / max: ' + parseInt(position.top + $(this).height()));
                        $(this).scrollspy({
                            min: position.top,
                            max: position.top + $(this).height(),
                            onEnter: function(element, position) {
                                if(console) console.log('entering.#red');
                                $("#red").children().fadeIn(200);},

                            onLeave: function(element, position) {
                                if(console) console.log('leaving.#red');
                                $("#red").children().fadeOut(200);}

                            /*onEnter: function(element, position) {
                                if(console) console.log('entering.#blue');
                                $(".test").show();},

                            onLeave: function(element, position) {
                                if(console) console.log('leaving.#blue');
                                $(".test").hide();}*/
                        });
                    });
                });
            </script>