I need some logical review on a part-solution I'm not satisfacted with. I have a table on my page (created with DataTables), so there's dynamic content which means the heigth and width of the table may vary. The table is embedded in three div wrappers (and yes, they are necessary) and I have to control the heigth of the outermost one so that the footer stays on the bottom of the page.
JSFiddle: http://jsfiddle.net/5hh9H/158/
This works fine, except when the content-height of the table and the footer-height are less than the window height.
Code I'm referring to:
if ($(window).height() < $("#wrapper").height()) {
$("#table-container").height($("#wrapper").height());
} else {
if ($(window).height() > $("#wrapper").height() + $("#footer").height() + 45) {
$("#table-container").height($(window).height() - $("#footer").height() - 45);
} else {
//Don't know, if this is necessary vv
$("#table-container").height($("#wrapper").height());
}
}
In that case, the footer is too low so that you can't see it when scrolled to the top. But any altering of the current function doesn't give me this smooth transition from footer moving with bottom to footer stopping beneath table (click "Shrink content!", scroll to bottom and decrease/increase window size). I want the footer to be visible on the bottom when the content is minimized and the page is scrolled to top!