Skip to content

Instantly share code, notes, and snippets.

@iamravenous
Last active April 23, 2024 09:05
Show Gist options
  • Save iamravenous/f06b341dbb8b0839a7b0 to your computer and use it in GitHub Desktop.
Save iamravenous/f06b341dbb8b0839a7b0 to your computer and use it in GitHub Desktop.
Smooth scrolling on page load if URL have a hash
/*
* Smooth Scroll on Pageload
* Smooth scrolling on page load if URL have a hash
* Author: Franco Moya - @iamravenous
*/
if (window.location.hash) {
var hash = window.location.hash;
if ($(hash).length) {
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 900, 'swing');
}
}
@mp111x000
Copy link

Wow - this is exactly what I meant, sorry for the confused question. Works like a breeze, many thanks Franco! And all the best in the New Year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment