I'm trying to make a smooth transition to a anchor within a page. The objective is when you click the link pointing to the anchor, the page fades out (scrolls) and fades in with the called anchor itself.
I have this mark-up, it fades in/out correctly, the URL changes to the called anchor, but it doesn't scroll to the called element
$(document).ready(function() {
$("a.transition").click(function(event) {
event.preventDefault();
linkLocation = this.href;
$(".container").fadeOut(500, redirectPage);
});
function redirectPage() {
window.location = linkLocation;
$(".container").fadeIn(500);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div id="A">This is A <a href="#B" class="transition">Go to B</a>
</div>
...some large text...
<div id="B" style="margin-top: 3000px;">This is B <a href="#A" class="transition">Go to A</a>
</div>
</div>