juankennaugh
8/13/2013 - 10:31 PM

smoothScroll.js

$(function() {
  $('a[rel=scroll]').smoothScroll();
});
(function($) {

  $.fn.smoothScroll = function() {
  
    return this.on('click', function() {
      var hash = $(this).attr('href');
      var dest = $(hash).offset();
      
      $('html:not(:animated),body:not(:animated)').animate({scrollTop: dest.top, scrollLeft: dest.left}, 500, function() {
        window.location.hash = hash;
      });
    
      return false;
    });
    
  };

})(jQuery);