ScrollToFixed icon indicating copy to clipboard operation
ScrollToFixed copied to clipboard

Short pages footer floats up

Open atutor opened this issue 10 years ago • 1 comments

I've been wrestling with how to get a scrolltofixed footer to sit at the bottom of a page that only fills about half of the screen. The footer always seems to float up to the bottom of the content, rather than sitting at the bottom of the screen. I can force it to sit at the bottom by explicitly setting the bottom position to 0, but then then footer does not hide away as expected when postFixed runs. Is there way to get the footer to sit at the bottom of the screen for short pages, while at the same time having the footer hide away as a user scrolls to the bottom of longer pages? Here's what I'm working with currently:


                $('#footer').scrollToFixed( {
                    bottom:0,
                    limit: $('#footer').offset().top - ($('#header').outerHeight()),
                    preFixed: function() {    
                       $('#footer').show("slow");
                        },
                    postFixed: function() {
                        $('#footer').hide("slow");
                        }
                });

The second problem I'm having is with the .show() and .hide() in the preFixed and postFixed functions. When scrolling down, postFixed correctly runs to hide the footer when visible page reaches the heigth of the #header div from the bottom of the screen, then when scrolling up it always seems to run PreFixed, PostFixed, and Prefixed. The result is the footer shows, then hides, then shows again in succession. How can I prevent the second loop through postFixed and PreFixed so the footer slides out when scrolling to the bottom of the page, then slides in (once) when scrolling up from the bottom of the page.

For context, this chunk of code runs within a larger jQuery(document).ready() in the following file about line 159: https://github.com/atutor/ATutor/blob/master/jscripts/ATutor_js.php

Any help would be appreciated.

atutor avatar Jul 01 '14 16:07 atutor