scroll to element outside viewport

I want to use a scrolling navigation which should scroll to elements outside the viewport (placed there so that with overflow-y: hidden nothing is visible) on click.

This is my implementation:

 $('#navbar a').click(
    function() {
        var el = $($(this).attr("href"));
        var offset = el.offset().top;, 0.8, { scrollTo: offset });

I want to scroll so that the element is centered at every resolution. I have seen some solutions: jQuery - Scroll element to the middle of the screen instead of to the top with an anchor link but this doesn't seem to work with elements outside viewport or I am missing something.