Last active
May 8, 2018 08:11
-
-
Save migliori/716105909561bc1e51e9ffff4602c89f to your computer and use it in GitHub Desktop.
Smooth scroll to anchor
This file contains hidden or 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
// anchors smooth scroll | |
$('a[href^="#"]').on('click', function() { | |
var $targetLink = $('#' + $.attr(this, 'href').substr(1)), | |
dataToggle = $(this).attr('data-toggle'); | |
if($targetLink[0] && dataToggle != 'modal' && dataToggle != 'collapse') { | |
$('html, body').animate({ | |
scrollTop: $targetLink.offset().top - 110 | |
}, 500); | |
} | |
return; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment