init.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. jQuery(document).ready(function($) {
  2. $('.nav-toggle').on( 'click', function() {
  3. $( this ).toggleClass( 'active' );
  4. });
  5. $(window).bind("load", function () {
  6. $('#loader').fadeOut(900);
  7. });
  8. var headerHeight = $('.navbar').height();
  9. $(window).on('scroll', { previousTop: 0 },
  10. function() {
  11. var currentTop = $(window).scrollTop();
  12. if (currentTop < this.previousTop) {
  13. if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
  14. $('.navbar').addClass('visible');
  15. } else {
  16. $('.navbar').removeClass('visible fixed');
  17. }
  18. } else {
  19. $('.navbar').removeClass('visible');
  20. if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
  21. }
  22. this.previousTop = currentTop;
  23. });
  24. var commentsDiv = $('#comments');
  25. if (commentsDiv.length) {
  26. $(commentsDiv).hide();
  27. $('.toggle-comments').on('click', function(e) {
  28. e.preventDefault();
  29. $(commentsDiv).toggle('slow', function() {
  30. var anchor = $('.toggle-comments');
  31. var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments';
  32. $(anchor).text(anchorText);
  33. });
  34. });
  35. }
  36. });
  37. ;(function ($) {
  38. 'use strict';
  39. var $body = $('html, body'),
  40. content = $('#big-top').smoothState({
  41. prefetch: true,
  42. pageCacheSize: 4,
  43. onStart: {
  44. duration: 250,
  45. render: function (url, $container) {
  46. content.toggleAnimationClass('is-exiting');
  47. $body.animate({
  48. scrollTop: 0
  49. });
  50. }
  51. }
  52. }).data('smoothState');
  53. })(jQuery);