Skip to content

Instantly share code, notes, and snippets.

@pabliqe
Last active July 26, 2016 09:41
Show Gist options
  • Save pabliqe/a80ceff520aa9ebdcce5dd1a54b4e01f to your computer and use it in GitHub Desktop.
Save pabliqe/a80ceff520aa9ebdcce5dd1a54b4e01f to your computer and use it in GitHub Desktop.
// usage smoothScrollTo.call([NodeElement])
function smoothScrollTo(completeCallback) {
// center element on screen
var posY = window.pageYOffset - (window.innerHeight / 2) + this.getBoundingClientRect().top + (this.offsetHeight / 2);
scrollAnimator = TweenLite.to(window, 1, {
scrollTo: {
y: posY
},
onComplete: function(){
if(typeof completeCallback === 'function')
completeCallback();
},
ease: Quint.easeInOut
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment