Last active
August 13, 2022 18:00
-
-
Save jgoslow/6eb7b17025f02395c94f0b83f30af069 to your computer and use it in GitHub Desktop.
JS Scrolling functions
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
function scrollToDiv(target) { | |
var loc = $(target).offset(); | |
jQuery("html,body").animate({ | |
scrollTop: loc.top-150//, | |
//scrollLeft: loc.left | |
}); | |
return false; | |
} |
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
function scrollToDiv(elem, scrollOffset=80) { | |
window.scroll({ | |
behavior: 'smooth', | |
left: 0, | |
top: elem.offsetTop - scrollOffset | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment