With the following code I managed to make the icon not go over the footer area, but instead remaing in the body.
This was requested by some clients, so here it is:

(function($) {
  Drupal.behaviors.scroll_top_top_not_over_footer = {
    attach: function (context, settings) {
      $(document).scroll(function() {
        if($('#back-top').offset().top + $('#back-top').height() >= $('footer').offset().top - 10)
          $('#back-top').css('bottom', $('footer').height() + 30);
          $('#back-top').css('transition', 'bottom 2s');
        if($(document).scrollTop() + window.innerHeight < $('footer').offset().top)
          $('#back-top').css('bottom', '10px'); // restore when you scroll up
      });
    }
  };
})(jQuery);

Comments

bserem created an issue.

bserem’s picture