Ads Manager 2 by Siropu

xF2 Add-on Ads Manager 2 by Siropu 2.4.21

No permission to download
Q. How to make the code ad in position "Sidebar below" fixed when scrolling down?
A. Place the following code below the ad code:

JavaScript:
<xf:js>
$(function()
{
     var unit = $('.samCodeUnit[data-position="container_sidebar_below"]');
     var stickyPoint = 0;

     function isSidebar()
     {
          return window.matchMedia('(min-width: 900px)').matches;
     }

     if (unit.length && isSidebar())
     {
          $(window).scroll(function()
          {
               var unitScrollOffset = unit.offset().top;
               var scrollTop = $(document).scrollTop();

               if (unitScrollOffset - scrollTop <= 0 && stickyPoint == 0)
               {
                    unit.css({position: 'fixed', top: $('.p-nav').height() + 10, width: 'auto'});
                stickyPoint = scrollTop;
               }
               else if (stickyPoint >= scrollTop)
               {
                    unit.css({position: '', top: '', width: ''});
                stickyPoint = 0;
               }
          });
     }

     $(window).resize(function()
     {
          if (!isSidebar())
          {
               unit.css({position: '', top: '', width: ''});
          }
     });
});
</xf:js>
Top