$(window).on("load scroll", function() { if ($(".history-list").length) { var el = $(".history-list"), item = el.find("> ul > li"), t = $(this), scrTop = t.scrollTop() + (t.height() / 1.75), scrTopE = t.scrollTop() + (t.height() / 1.8), conTop = el.offset().top, conH = el.height(), prog = $(".progress"), itemPos = new Array, itemH = new Array; item.each(function(index) { var t = $(this); itemPos.push(t.offset().top); itemH.push(t.outerHeight()); var per = Math.floor((scrTop - conTop) / (conH) * 100); if (per <= 95) { prog.css("height", per + "%"); } else if (per > 96) { prog.css("height", 100 + "%"); } else if (per < 10) { prog.css("height", 0 + "%"); } if (scrTopE >= itemPos[index]) { t.addClass("effect"); } else { t.removeClass("effect"); } }); } });