top) { if (positions[i].pos-top < windowHeight/2 ) { return positions[i].el; } else { return previous; } } previous = positions[i].el; } } function scrollWindow() { var targetItem = getCurrentItem(); if (targetItem !== currentItem) { if (currentItem) { currentItem.removeClass("active"); } currentItem = targetItem; if (currentItem) { currentItem.addClass("active"); } } } $(window).resize(resizeWindow); $(window).on("…