Created
July 4, 2019 17:21
-
-
Save ksmandersen/dc350576cef267a44ef67c63a3e2da92 to your computer and use it in GitHub Desktop.
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
export const scrollToElement = (id, position) => { | |
const element = document.getElementById(id); | |
if (element) { | |
element.scrollIntoView({ | |
behavior: 'smooth', | |
block: position, | |
}); | |
} | |
}; | |
export const scrollToContact = (position = 'center') => | |
scrollToElement('contact_form', position); | |
export const scrollToTop = () => { | |
window.scrollTo(0, 0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment