4 Replies - 924 Views - Last Post: 26 June 2016 - 09:32 AM

#1 mbole87   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-November 14

Scrolling sidebar - prevent pushing footer down

Posted 26 June 2016 - 05:32 AM

I have a problem with my scrolling sidebar. It work's good, but on some resolution when comes to the end sidebar push footer down. I guess I should detect if the sidebar has touch the footer and then disable scrolling. I try something like this, but without success. Does anyone have an idea how to fix this?

Thank you,

Here is a link of page My link

var windowWidth = $(window).width();
function scrollSidebar() {
    if ($('.no-scroll').css('float') != 'none') {
        var headerHeight = $('.header').outerHeight();
        var sidebar = $('.sidebar-wrap');
        var sidebarOffset = $('.sidebar-wrap').offset().top;
        var sidebarTopPadding = 125;
        $(window).scroll(function() {
            if ($(window).scrollTop() > headerHeight ) {
                sidebar.stop().animate({
                    marginTop: $(window).scrollTop() - 60
                }, 200);
            } 
            else {
                sidebar.stop().animate({
                    marginTop: 0
                }, 200);
            }
        });
    }
}
scrollSidebar();
$(window).resize(function() {
    if ($('.no-scroll').css('float') == 'none') {
        scrollSidebar();
        if (window.RT) clearTimeout(window.RT);
        window.RT = setTimeout(function()
        {
            this.location.reload(false); 
        }, 200);
    }
});



Is This A Good Question/Topic? 0
  • +

Replies To: Scrolling sidebar - prevent pushing footer down

#2 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Scrolling sidebar - prevent pushing footer down

Posted 26 June 2016 - 08:42 AM

On my small screen I cannot see the last two numbered items at all. If I reduce the bottom margin of "table of contents" from 50px to 20px, and the bottom margin between each li item to 20px, then I can read all the items comfortably and the problem with the footer disappears.. because the TOC doesn't reach it.

On a mini laptop though (a netbook or tablet) the problem might resurface (excuse the pun). I would prefer to continue squeezing the height, or perhaps reducing the number of items, rather than resort immediately to jQuery. (The more we try to fix things with jQuery, the more things that can go wrong, especially amongst the huge variety of media that we are trying to facilitate.)
Was This Post Helpful? 1
  • +
  • -

#3 mbole87   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-November 14

Re: Scrolling sidebar - prevent pushing footer down

Posted 26 June 2016 - 09:15 AM

Thank you @andrewsw,

I think the same as you, I tried a lot of ways, and in the end I reduced sidebar css (li font , margin-bottom ..) i think it is about ok.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Scrolling sidebar - prevent pushing footer down

Posted 26 June 2016 - 09:23 AM

"Occam's razor is more commonly described as 'the simplest answer is most often correct,'"
Was This Post Helpful? 1
  • +
  • -

#5 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Scrolling sidebar - prevent pushing footer down

Posted 26 June 2016 - 09:32 AM

(I must try and squeeze ontological parsimony into a sentence today ;) )
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1