What else we had except good ole JS: we have jQuery.
What limitations we have: IE8. We have to support it.
So, the first solution that comes to mind is, get the last visible element, get its position, and try to calculate the needed window height based on this. Like that:
var lastEl = $(":visible:last"); var width = $(window).width(); var height = lastEl.position.top() + lastEl.height + 30; // last figure is just some margin window.resizeTo(width, height);
Unfortunately, we discovered that it doesn’t work as intended. Yes, the window was resized, but each time the scroll was still visible. We tried to use $(document).height() instead of our lastEl calculation, because the spec says that it shows the whole doc height, not just the visible viewport, but still no luck. We still had that scroll, and it looked like we needed to add another variable to our sum: the difference between window.innerHeight and window.outerHeight.
But these two properties don’t come till IE9!
So, what worked in the end was this small code snippet:
var w = $(window), d = $(document), b = $('body'); window.resizeBy(0, ((b.height() - w.height()) || d.height() - w.height()));
You just had to call it when all the data is loaded to the view, so that the view has its final dimensions.