Last active
August 25, 2016 22:17
-
-
Save alexmahan/f268db2532963f7081a1920d0fe98b23 to your computer and use it in GitHub Desktop.
Simple scrollTo method using Typescript and Greensock
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
scrollToElem(e): void { | |
e.preventDefault(); | |
const target = { | |
y: window.scrollY, | |
}; | |
const elemTopPos = this.anyElem.offsetTop; | |
TweenMax.to(target, 0.5, { | |
y: elemTopPos, | |
onUpdate: () => { | |
window.scrollTo(0, target.y); | |
}, | |
ease: Quart.easeOut, | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment