Skip to content

Instantly share code, notes, and snippets.

@unwiredtech
Last active August 5, 2018 16:08
Show Gist options
  • Save unwiredtech/7eb6ed584beac9f58ce7404254016252 to your computer and use it in GitHub Desktop.
Save unwiredtech/7eb6ed584beac9f58ce7404254016252 to your computer and use it in GitHub Desktop.
OptimizePress 2.0 Smooth Scroll
/* Optimize Press 2.0 Smooth Scroll */
/* Add this to your page-setting */
/* Anchor tag jump will be smooth */
<script>
opjq(function($) {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment