Created
September 6, 2017 11:34
-
-
Save Jursdotme/160255c9c3874c5d086bf3888c6e202e to your computer and use it in GitHub Desktop.
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
/* ========== Smooth Scroll ========== */ | |
( | |
function ( $ ) { | |
$.fn.vantageSmoothScroll = function () { | |
$( this ).click( function ( e ) { | |
var $a = $( this ); | |
var $target = $( '[name=' + this.hash.slice( 1 ) + ']' ).length ? $( '[name=' + this.hash.slice( 1 ) + ']' ) : $( $a.get( 0 ).hash ); | |
if ( $target.length ) { | |
var height = 0; | |
if ( $( '.site-navigation' ).hasClass( 'use-sticky-menu' ) ) { | |
height += $( '.site-navigation' ).outerHeight(); | |
} | |
if ( $( 'body' ).hasClass( 'admin-bar' ) ) { | |
height += $( '#wpadminbar' ).outerHeight(); | |
} | |
$( 'html, body' ).animate( { | |
scrollTop: $target.offset().top - height | |
}, 1000 ); | |
return false; | |
} | |
// Scroll to the position of the item, minus the header size | |
} ); | |
} | |
} | |
)( jQuery ); | |
( function($) { | |
$(window).load( function() { | |
// Handle smooth scrolling | |
$( '#site-navigation a[href*="#"]:not([href="#"])' ).add( 'a[href*="#"]:not([href="#"])' ).not( '.lsow-tab a[href*="#"]:not([href="#"]), .wc-tabs a[href*="#"]:not([href="#"]), .iw-so-tab-title a[href*="#"]:not([href="#"]), .comment-navigation a[href*="#"]' ).vantageSmoothScroll(); | |
} ); | |
} )(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Thanks for this code but how to smooth scroll when page loaded please.
Thank you.