function isScrolledIntoView(elem) { var docViewTop = jQuery(window).scrollTop(); var docViewBottom = docViewTop + jQuery(window).height(); var elemTop = jQuery(elem).offset().top; var elemBottom = elemTop + jQuery(elem).height(); return ( (elemTop <= docViewBottom) && (elemTop >= docViewTop) || (elemBottom <= docViewBottom) && (elemBottom >= docViewTop) ); } jQuery('#our_a_left_desktop').html('
'); function renderALeftOrMobileBottom() { window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ blockId: "R-A-645045-4", renderTo: "yandex_rtb_R-A-645045-4" }) }); } renderALeftOrMobileBottom(); setInterval(function(){ if (isScrolledIntoView('#yandex_rtb_R-A-645045-4')) { console.log('Reload left or mobile bottom block'); renderALeftOrMobileBottom(); } }, 30000);