A better alternative to window.scrollTop?

A better alternative to window.scrollTop?

I am relatively new to jQuery but I've been able to use it to create a header that changes when the user scrolls. I've been using the following code to make it work: 
  1. jQuery(document).ready(function($) {

    $(window).scroll(function() {
    if ($(this).scrollTop() > 0) {

    if ($(window).scrollTop() > 20) {
    $('.move-logo').css({"transition-duration":".4s","height":"60px", "width":"90px","left":"44.7vw"}, 800);
    $('.site-header').css({"transition-duration":".4s","border-bottom":"solid","border-color":"#4494cd"}).removeClass("site-header-clear").addClass("site-header-white");
    $('.mobile-logo').css({"position":"relative","bottom":"10px","left":"0"});
    $('.nav-menu').find('a').removeClass("menu-links");
    $('.sub-menu').find('a').removeClass("sub-menu-links");
    }
     if ($(window).scrollTop() < 20) {
     $('.move-logo').css({"height":"95px","width":"135px"});
     $('.site-header').css({"transition-duration":".2s","border-bottom":"none"}).removeClass("site-header-white").addClass("site-header-clear");
     $('.move-logo').css("left","0");
     $('.nav-menu').find('a').addClass("menu-links");
     $('.sub-menu').find('a').addClass("sub-menu-links");
      }

               }

    });



    });
I know this is not the neatest code and there are several things I can do to clean it up, but it produces the effect that I want so I am pretty much satisfied with it right now. The only problem I am having is that the browser does not always recognize that the user has scrolled back to the top, or < 20, and the header that appears after being scrolled stays on the screen instead of reverting back to the original header. 

My question is: is there a better way to get this effect or make it work more smoothly using jQuery?

You can see my header at www.gracemedicaloffice.com (I don't care if you click on the link or not I promise I am not trying to spam anyone). 

Again, I know my code is not the greatest I am just trying to improve on what I have now and hopefully learn something.