Last active
October 2, 2017 14:45
-
-
Save lukasborawski/cd387c101b5dc2b7c9a6f73c88cd8ee6 to your computer and use it in GitHub Desktop.
Scroll to Element for Angular 2
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
scrollToBottom () { | |
function offset(el:any) { | |
let rect = el.getBoundingClientRect(), | |
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft, | |
scrollTop = window.pageYOffset || document.documentElement.scrollTop; | |
return { top: rect.top + scrollTop, left: rect.left + scrollLeft } | |
} | |
let content = document.getElementById('content') | |
if (content) { | |
let offsetTop = offset(content).top | |
window.scrollTo(0, offsetTop) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment