1// Timeline Scroll Section 2// -------------------------------------------------------------- 3var items = $(".timeline li"), 4 timelineHeight = $(".timeline ul").height(), 5 greyLine = $('.default-line'), 6 lineToDraw = $('.draw-line'); 7 8// Run this function only if draw line exists on the page 9if (lineToDraw.length) { 10 $(window).on('scroll', function () { 11 12 // Constants and dynamically calculated values 13 var greyLineHeight = greyLine.height(), 14 windowDistance = $(window).scrollTop(), 15 windowHeight = $(window).height() / 2, 16 timelineDistance = $(".timeline").offset().top; 17 18 // Calculate the position of the last checkpoint 19 var lastCheckpoint = $(".timeline li:last-child").offset().top; 20 21 // Max height for both lines 22 var maxHeight = lastCheckpoint - $(".timeline").offset().top; 23 24 // Update the draw-line height 25 if (windowDistance >= timelineDistance - windowHeight) { 26 var line = windowDistance - timelineDistance + windowHeight; 27 28 if (line <= greyLineHeight && line <= maxHeight) { 29 lineToDraw.css({ 30 'height': line + 20 + 'px' 31 }); 32 } else if (line > maxHeight) { 33 lineToDraw.css({ 34 'height': maxHeight + 12 + 'px' 35 }); 36 } 37 } 38 39 // Ensure the default-line ends at the last checkpoint 40 greyLine.css({ 41 'height': maxHeight + 12 + 'px' 42 }); 43 44 // Add the class 'in-view' to the visible li elements and 'dark-color' to their h2 45 var bottom = lineToDraw.offset().top + lineToDraw.outerHeight(true); 46 items.each(function () { 47 var circlePosition = $(this).offset(), 48 sectionH2 = $(this).find(".section-h2"); // Get the h2 inside this li 49 50 if (bottom > circlePosition.top) { 51 $(this).addClass('in-view'); 52 sectionH2.addClass('dark-color'); // Add class to h2 53 } else { 54 $(this).removeClass('in-view'); 55 sectionH2.removeClass('dark-color'); // Remove class from h2 56 } 57 }); 58 }); 59}
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.