$(function(){ var item = $(".items-mobile"), ani_item = item.find(".animated"); console.log(item); $(window).on("scroll load", function () { var scrolltop = $(document).scrolltop(); var h = $(window).height(); ani_item.each(function () { var itemtotop = $(this).offset().top; var itemh = $(this).outerheight(); var ani_name = $(this).attr("ani-name"), ani_delay = $(this).attr("ani-delay"), ani_duration = $(this).attr("ani-duration"); if (scrolltop + h >= $(this).parent().offset().top + (itemh / 3)) { $(".items-steps .items-block").find(this).removeclass("hidden").addclass(ani_name).css({ "animation-delay": ani_delay, "animation-duration": ani_duration }); } if (scrolltop + h >= itemtotop + (itemh / 3)) { $(this).removeclass("hidden").addclass(ani_name).css({ "animation-delay": ani_delay, "animation-duration": ani_duration }); } }); }); })