let scroll_animation = function(selectors, type) { let body = $("body"); if (!body.hasClass("wd-scroll-animation-init")) { /* $(".s_title, .s_line, .s_button, .e_timeFormat-8, .e_richText-18, [class*='e_text'], .e_websiteShare-31").addClass("wd-scroll-animation");*/ body.addClass("wd-scroll-animation-init"); let num = 0; $(window).scroll(function() { num = 0; }); function ani(a, t) { var top = a.offset().top; if (top < ($(window).height() + t - 100)) { a.addClass("wd-scroll-in"); setTimeout(function() { a.addClass("wd-scrolled"); }, 200 + num * 100); num++; } } function handle() { let t = $(window).scrollTop(); let body_height = body.height(); $(".wd-scroll-animation:not(.wd-scroll-in):not(.wd-no-scroll-animation)").each(function() { ani($(this), t); }); if ($(window).height + t + 200 >= body_height) { $(".wd-scroll-animation:not(.wd-scroll-in):not(.wd-no-scroll-animation)").each(function() { $(this).addClass("wd-scroll-in").addClass("wd-scrolled"); }); } requestAnimationFrame(handle); } requestAnimationFrame(handle); } $(selectors).addClass("wd-scroll-animation").each(function() { if (type) { $(this).addClass(type) } }); return scroll_animation; };