Skip to content

Instantly share code, notes, and snippets.

@alexmahan
Last active August 25, 2016 22:17
Show Gist options
  • Save alexmahan/f268db2532963f7081a1920d0fe98b23 to your computer and use it in GitHub Desktop.
Save alexmahan/f268db2532963f7081a1920d0fe98b23 to your computer and use it in GitHub Desktop.
Simple scrollTo method using Typescript and Greensock
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