Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sorcamarian/f702f676cbaef0cf02f8b8e9607a5519 to your computer and use it in GitHub Desktop.
Save sorcamarian/f702f676cbaef0cf02f8b8e9607a5519 to your computer and use it in GitHub Desktop.
YUI().use('node', 'anim', function (Y) {
Y.on('domready', function () {
(function () {
Y.one('body').delegate('click', function (e) {
e.preventDefault();
var anchor = e.currentTarget.getAttribute('href');
var scrollAnim = new Y.Anim({
node: Y.one(Y.UA.gecko || Y.UA.ie || !!navigator.userAgent.match(/Trident.*rv.11\./) ? 'html' : 'body'),
to: {
scrollTop : Y.one(anchor).getY()
},
duration: 0.4,
easing: 'easeOut'
});
scrollAnim.run();
scrollAnim.on('end', function () {
window.location.hash = anchor;
});
}, '[href^="#"]');
})();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment