_script_scroll.haml 589 B

12345678910111213141516171819202122
  1. :javascript
  2. $(function(){
  3. function scrollToHash() {
  4. var hash = document.location.hash,
  5. target = $('.column-content h3 a[href^=' + hash + ']'),
  6. position;
  7. if (target.length) {
  8. position = target.offset().top - 60;
  9. $("html, body").animate({scrollTop:position}, 250, "swing");
  10. }
  11. }
  12. $(window).on('hashchange', scrollToHash);
  13. // When clicked
  14. $('a[href^=#]').click(function(){
  15. document.location.hash = $(this).attr("href");
  16. return false;
  17. });
  18. // When loaded
  19. $(window).trigger('hashchange');
  20. });