I am trying to make a class fade in when 'register' class div top enters the window and otherwise have the class fade out
How can I make this work?
$(window).scroll(function() {
  var tint = $('.register').offset().top;
  if ($(this).scrollTop() > tint) {
    $('.tint').fadeIn(1000);
  } else {
    $('.tint').fadeOut(1000);
  }
});section {
    height: 100vh;
    width: 100%;
}
.tint {
  background-color: #000;
  width: 100%;
  height: 100vh;
  opacity: 0.6;
  position: absolute;
  top: 0;
}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section></section>
<section class="register">
  <div class="tint"></div>
  <div>Content</div>
</section> 
     
    