One of my website elements is a drop anchor that connects from a downwards arrow situated at the bottom of a full-page parallax image to another section on the same page. The HTML code snippet for the drop anchor is as follows:
<section id="first" class="big-image parallax lander" style="background-image: url("https://wagstaffsandbx.wpengine.com/wp-content/uploads/2017/06/Homepage-Photo-1.jpg"); background-position: 50% -7.2px;" data-stellar-background-ratio="0.2" data-stellar-vertical-offset="50">
<a href="#welcome" class="arrow"><img class="down-arrow" src="https://wagstaffsandbx.wpengine.com/wp-content/uploads/2017/06/down-arrow.png" alt="down-arrow"></a>
</section>
The destination of this drop anchor is defined in the following HTML code snippet:
<section id="welcome" class="text-block"><h1>welcome</h1><p>Pitchfork mumblecore stumptown, intelligentsia wolf put a bird on it man bun wayfarers organic actually sartorial. Sriracha disrupt kickstarter fingerstache selvage pour-over. Paleo ugh lumbersexual, kinfolk banjo banh mi meditation cliche 3 wolf moon single-origin coffee viral blog polaroid pop-up.</p>
</section>
Although clicking on the arrow triggers the smooth scroll to the drop anchor location, there seems to be an issue where the scroll jumps downward unnecessarily after reaching the destination. I have included the jQuery script responsible for the smooth scrolling below. Note that there is a specified offset of 140px for navigation:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
// Add smooth scrolling to all links
$("a.arrow").on('click', function(event) {
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top -140
}, 800, function(){
window.location.hash = hash;
});
} // End if
});
});
</script>
To witness the issue firsthand, you can visit the following link:
To access the site demo, use UN: demo and PW: password when prompted.
Any thoughts or suggestions on how to resolve this issue?