diff options
author | Anton L. Šijanec <anton@sijanec.eu> | 2020-04-28 22:53:07 +0200 |
---|---|---|
committer | Anton L. Šijanec <anton@sijanec.eu> | 2020-04-28 22:53:07 +0200 |
commit | aeef95ae52a73544681b45e387f7dd580e88e011 (patch) | |
tree | e2044669ab7835f0f6ee56db6ec9ce828a0e3979 /layout/js/clean-blog.js | |
parent | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaauuu (diff) | |
download | bverbose-aeef95ae52a73544681b45e387f7dd580e88e011.tar bverbose-aeef95ae52a73544681b45e387f7dd580e88e011.tar.gz bverbose-aeef95ae52a73544681b45e387f7dd580e88e011.tar.bz2 bverbose-aeef95ae52a73544681b45e387f7dd580e88e011.tar.lz bverbose-aeef95ae52a73544681b45e387f7dd580e88e011.tar.xz bverbose-aeef95ae52a73544681b45e387f7dd580e88e011.tar.zst bverbose-aeef95ae52a73544681b45e387f7dd580e88e011.zip |
Diffstat (limited to '')
-rw-r--r-- | layout/js/clean-blog.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/layout/js/clean-blog.js b/layout/js/clean-blog.js new file mode 100644 index 0000000..2930d5f --- /dev/null +++ b/layout/js/clean-blog.js @@ -0,0 +1,41 @@ +(function($) { + "use strict"; // Start of use strict + + // Floating label headings for the contact form + $("body").on("input propertychange", ".floating-label-form-group", function(e) { + $(this).toggleClass("floating-label-form-group-with-value", !!$(e.target).val()); + }).on("focus", ".floating-label-form-group", function() { + $(this).addClass("floating-label-form-group-with-focus"); + }).on("blur", ".floating-label-form-group", function() { + $(this).removeClass("floating-label-form-group-with-focus"); + }); + + // Show the navbar when the page is scrolled up + var MQL = 992; + + //primary navigation slide-in effect + if ($(window).width() > MQL) { + var headerHeight = $('#mainNav').height(); + $(window).on('scroll', { + previousTop: 0 + }, + function() { + var currentTop = $(window).scrollTop(); + //check if user is scrolling up + if (currentTop < this.previousTop) { + //if scrolling up... + if (currentTop > 0 && $('#mainNav').hasClass('is-fixed')) { + $('#mainNav').addClass('is-visible'); + } else { + $('#mainNav').removeClass('is-visible is-fixed'); + } + } else if (currentTop > this.previousTop) { + //if scrolling down... + $('#mainNav').removeClass('is-visible'); + if (currentTop > headerHeight && !$('#mainNav').hasClass('is-fixed')) $('#mainNav').addClass('is-fixed'); + } + this.previousTop = currentTop; + }); + } + +})(jQuery); // End of use strict |