Skip to content

Instantly share code, notes, and snippets.

@kurt-chainlink
Last active November 12, 2020 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurt-chainlink/6124927837fb76a17f2e13c265ad76fa to your computer and use it in GitHub Desktop.
Save kurt-chainlink/6124927837fb76a17f2e13c265ad76fa to your computer and use it in GitHub Desktop.
<script>
jQuery(document).ready(function( $ ){
$( 'a[href*="#"]:not([href="#"])' ).click( function() {
var $this_link = $( this ),
has_closest_smooth_scroll_disabled = $this_link.closest( '.et_smooth_scroll_disabled' ).length,
has_closest_woocommerce_tabs = ( $this_link.closest( '.woocommerce-tabs' ).length && $this_link.closest( '.tabs' ).length ),
has_closest_timetable_tab = $this_link.closest( '.tt_tabs_navigation' ).length,
has_closest_eab_cal_link = $this_link.closest( '.eab-shortcode_calendar-navigation-link' ).length,
has_closest_ee_cart_link = $this_link.closest( '.view-cart-lnk' ).length,
has_acomment_reply = $this_link.hasClass( 'acomment-reply' ),
is_woocommerce_review_link = $this_link.hasClass( 'woocommerce-review-link' ),
disable_scroll = has_closest_smooth_scroll_disabled || has_closest_ee_cart_link || has_closest_woocommerce_tabs || has_closest_eab_cal_link || has_acomment_reply || is_woocommerce_review_link || has_closest_timetable_tab;
if ( ( location.pathname.replace( /^\//,'' ) == this.pathname.replace( /^\//,'' ) && location.hostname == this.hostname ) && ! disable_scroll ) {
var target = $( this.hash );
target = target.length ? target : $( '[name=' + this.hash.slice(1) +']' );
if ( target.length ) {
// automatically close fullscreen menu if clicked from there
if ( $this_link.closest( '.et_pb_fullscreen_menu_opened' ).length > 0 ) {
et_pb_toggle_fullscreen_menu();
}
setTimeout(function() {
et_pb_smooth_scroll( target, false, 0 );
}, 0);
if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) {
setTimeout(function(){
et_pb_smooth_scroll( target, false, 0, 'linear' );
}, 0 );
}
return false;
}
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment