Skip to content

Instantly share code, notes, and snippets.

@rickrduncan
Last active January 3, 2016 07:09
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 rickrduncan/8428019 to your computer and use it in GitHub Desktop.
Save rickrduncan/8428019 to your computer and use it in GitHub Desktop.
jQuery for smooth scrolling to top of page.
<?php
//* Do NOT include the opening php tag
//* Add Core JS file
add_action( 'wp_enqueue_scripts', 'b3m_add_core_js' );
if ( ! function_exists( 'b3m_add_core_js' ) ) {
function b3m_add_core_js() {
wp_enqueue_script( 'core-js', get_stylesheet_directory_uri() . '/lib/js/core.js', array('jquery'), '1.0.0', true );
}
}
//* Smooth scrolling
jQuery(document).ready(function() {
var duration = 800;
jQuery('.smooth-scroll').click(function(event) {
event.preventDefault();
jQuery('html, body').animate({scrollTop: 0}, duration);
return false;
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment