Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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