Last active
August 5, 2018 16:08
-
-
Save unwiredtech/7eb6ed584beac9f58ce7404254016252 to your computer and use it in GitHub Desktop.
OptimizePress 2.0 Smooth Scroll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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