Skip to content

Instantly share code, notes, and snippets.

@juanbrujo
Created September 27, 2018 13:06
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 juanbrujo/a8b54ed03caa6fd804abbb5edf620965 to your computer and use it in GitHub Desktop.
Save juanbrujo/a8b54ed03caa6fd804abbb5edf620965 to your computer and use it in GitHub Desktop.
scrollBehavior(to) {
if (to.hash) {
return window.scrollTo({
top: document.querySelector(to.hash).offsetTop - 100,
behavior: 'smooth'
});
} else {
return setTimeout(() => {
window.scrollTo({
top: 0
})
}, 300) //tengo un transition, por eso
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment