Blog-style website for karathan using the self-made Stellar Theme powered by HTML5Up http://blog.karathan.at

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. Stellar by HTML5 UP
  3. html5up.net | @ajlkn
  4. Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
  5. */
  6. (function($) {
  7. var $window = $(window),
  8. $body = $('body'),
  9. $main = $('#main');
  10. // Breakpoints.
  11. breakpoints({
  12. xlarge: [ '1281px', '1680px' ],
  13. large: [ '981px', '1280px' ],
  14. medium: [ '737px', '980px' ],
  15. small: [ '481px', '736px' ],
  16. xsmall: [ '361px', '480px' ],
  17. xxsmall: [ null, '360px' ]
  18. });
  19. // Play initial animations on page load.
  20. $window.on('load', function() {
  21. window.setTimeout(function() {
  22. $body.removeClass('is-preload');
  23. }, 100);
  24. });
  25. // Nav.
  26. var $nav = $('#nav');
  27. if ($nav.length > 0) {
  28. // Shrink effect.
  29. $main
  30. .scrollex({
  31. mode: 'top',
  32. enter: function() {
  33. $nav.addClass('alt');
  34. },
  35. leave: function() {
  36. $nav.removeClass('alt');
  37. },
  38. });
  39. // Links.
  40. var $nav_a = $nav.find('a');
  41. $nav_a
  42. .scrolly({
  43. speed: 1000,
  44. offset: function() { return $nav.height(); }
  45. })
  46. .on('click', function() {
  47. var $this = $(this);
  48. // External link? Bail.
  49. if ($this.attr('href').charAt(0) != '#')
  50. return;
  51. // Deactivate all links.
  52. $nav_a
  53. .removeClass('active')
  54. .removeClass('active-locked');
  55. // Activate link *and* lock it (so Scrollex doesn't try to activate other links as we're scrolling to this one's section).
  56. $this
  57. .addClass('active')
  58. .addClass('active-locked');
  59. })
  60. .each(function() {
  61. var $this = $(this),
  62. id = $this.attr('href'),
  63. $section = $(id);
  64. // No section for this link? Bail.
  65. if ($section.length < 1)
  66. return;
  67. // Scrollex.
  68. $section.scrollex({
  69. mode: 'middle',
  70. initialize: function() {
  71. // Deactivate section.
  72. if (browser.canUse('transition'))
  73. $section.addClass('inactive');
  74. },
  75. enter: function() {
  76. // Activate section.
  77. $section.removeClass('inactive');
  78. // No locked links? Deactivate all links and activate this section's one.
  79. if ($nav_a.filter('.active-locked').length == 0) {
  80. $nav_a.removeClass('active');
  81. $this.addClass('active');
  82. }
  83. // Otherwise, if this section's link is the one that's locked, unlock it.
  84. else if ($this.hasClass('active-locked'))
  85. $this.removeClass('active-locked');
  86. }
  87. });
  88. });
  89. }
  90. // Scrolly.
  91. $('.scrolly').scrolly({
  92. speed: 1000
  93. });
  94. })(jQuery);
  95. function topFunction() {
  96. document.body.scrollTop = 0; // For Safari
  97. document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
  98. }