Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function smoothscroll_script() { ?>
- <script>
- jQuery(document).ready(function($) {
- $('a[href^="#"][href!="#"], .smoothscroll, .smoothscroll a').click(function(e) {
- e.preventDefault();
- e.stopPropagation();
- var url = $(this).attr('href'),
- hash = url.substring(url.indexOf('#'));
- scrollTo(hash);
- });
- });
- jQuery(window).load(function($) {
- if (window.location.hash)
- scrollTo(window.location.hash);
- });
- function scrollTo(hash) {
- var offset = jQuery(hash).offset().top,
- headerHeight = 50,
- wpAdminBarHeight = jQuery('html').css("margin-top").replace(/[^-\d\.]/g, '');
- jQuery('html, body').stop().animate({
- scrollTop: (offset - headerHeight - wpAdminBarHeight)
- }, 1500,'easeInOutExpo', function() { window.location.hash = "" + hash; });
- }
- </script>
- <?php
- }
- add_action( 'wp_footer', 'smoothscroll_script' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement