Last active
July 26, 2016 09:41
-
-
Save pabliqe/a80ceff520aa9ebdcce5dd1a54b4e01f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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