1(function(window){ 2 var defaults = { 3 floorClass : '.scroll-floor', 4 navClass : '.scroll-nav', 5 activeClass : 'active', 6 activeTop : 100, 7 scrollTop : 100, 8 delayTime : 200 9 }; 10 11 var $body = $('body'),floorList = null,navList = null; 12 function getItem(_list,newOptions){ 13 var data = []; 14 _list.each(function() { 15 var item = {}; 16 item.$obj = $body.find(this); 17 item.$activeTop = $body.find(this).offset().top - newOptions.activeTop; 18 item.$scrollTop = $body.find(this).offset().top + newOptions.scrollTop; 19 20 data.push(item); 21 }); 22 return data; 23 } 24 25 function scrollActive(_list,newOptions){ 26 var nowScrollTop = $(window).scrollTop(); 27 var data = getItem(floorList,newOptions); 28 29 $.each(data,function(i,item){ 30 if(nowScrollTop > item.$activeTop){ 31 _list.removeClass(newOptions.activeClass).eq(i).addClass(newOptions.activeClass); 32 } 33 }); 34 } 35 36 function clickActive(_index,newOptions){ 37 var data = getItem(floorList,newOptions); 38 $('html,body').animate({'scrollTop' : data[_index].$scrollTop},newOptions.delayTime); 39 } 40 41 var scroll_floor = window.scrollFloor = function(options){ 42 var newOptions = $.extend({}, defaults, options); 43 floorList = $body.find(newOptions.floorClass); 44 navList = $body.find(newOptions.navClass); 45 46 47 scrollActive(navList,newOptions); 48 49 $(window).bind('scroll',function(){scrollActive(navList,newOptions);}); 50 navList.bind('click',function(){ 51 var _index = $body.find(this).index(); 52 clickActive(_index,newOptions); 53 }); 54 } 55})(window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.