1jQuery(document).ready(function($){ 2 //variables 3 var $window = $(window); 4 var $container = $(".sidebar-nav"); 5 var $main = $(".advising-body"); 6 var window_min = 0; 7 var window_max = 0; 8 var threshold_offset = 225; 9 /* 10 set the container's maximum and minimum limits as well as movement thresholds 11 */ 12 function set_limits(){ 13 //max and min container movements 14 var max_move = $main.offset().top + $main.height() - $container.height() - 2*parseInt($container.css("top") ); 15 var min_move = $main.offset().top; 16 //save them 17 $container.attr("data-min", min_move).attr("data-max",max_move); 18 //window thresholds so the movement isn't called when its not needed! 19 //you may wish to adjust the freshhold offset 20 window_min = min_move - threshold_offset; 21 window_max = max_move + $container.height() + threshold_offset; 22 } 23 //sets the limits for the first load 24 set_limits(); 25 26 function window_scroll(){ 27 //if the window is within the threshold, begin movements 28 if( $window.scrollTop() >= window_min && $window.scrollTop() < window_max ){ 29 //reset the limits (optional) 30 set_limits(); 31 //move the container 32 container_move(); 33 } 34 } 35 $window.bind("scroll", window_scroll); 36 37 /** 38 * Handles moving the container if needed. 39 **/ 40 function container_move(){ 41 var wst = $window.scrollTop(); 42 //if the window scroll is within the min and max (the container will be "sticky"; 43 if( wst >= $container.attr("data-min") && wst <= $container.attr("data-max") ){ 44 //work out the margin offset 45 var margin_top = $window.scrollTop() - $container.attr("data-min"); 46 //margin it down! 47 $container.css("margin-top", margin_top); 48 //if the window scroll is below the minimum 49 }else if( wst <= $container.attr("data-min") ){ 50 //fix the container to the top. 51 $container.css("margin-top",0); 52 //if the window scroll is above the maximum 53 }else if( wst > $container.attr("data-max") ){ 54 //fix the container to the top 55 $container.css("margin-top", $container.attr("data-max")-$container.attr("data-min")+"px" ); 56 } 57 } 58 //do one container move on load 59 container_move(); 60});
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.