Good day! Tell me, please, how to make the script execute block animation when the block reaches the center of the screen, and not when it only becomes visible, as I have now. Thank you for your help!
$(function() { $('.person').css({'margin-left':'50px'}); $(window).on('scroll', function(e) { if ($(window).scrollTop() > $('.person').offset().top - $(window).height()) { $('.person').css({'margin-left':'10px'}); } }); }); .person { margin-left: 10px; transition: margin-left .4s; } p { height: 700px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <p></p> <div class="person"><img alt="" src="https://i02.fotocdn.net/s16/240/gallery_xs/254/54328815.jpg"></div> <p></p>