Guest User

Untitled

a guest
Oct 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. console.log(to)
  2. let x = 0
  3. let y = 0
  4. let el
  5. let elTop
  6. let isSamePageLink = to.hash.length && to.hash.match(/#\/[A-z0-9]/) === null
  7. if (isSamePageLink) {
  8. el = document.getElementByID(to.hash)
  9. elTop = el ? el.offsetTop : 0
  10.  
  11. window.scrollTo(0, elTop)
  12. console.log('internal scroll')
  13. } else {
  14. window.scrollTo(x, y)
  15. console.log('normal route change')
  16. }
Add Comment
Please, Sign In to add comment