Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miguelsimoni/hugo-initio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/template.js')
-rw-r--r--assets/js/template.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/assets/js/template.js b/assets/js/template.js
new file mode 100644
index 0000000..c000467
--- /dev/null
+++ b/assets/js/template.js
@@ -0,0 +1,38 @@
+jQuery(document).ready(function ($) {
+
+ var my_nav = $('.navbar-sticky');
+ // grab the initial top offset of the navigation
+ var sticky_navigation_offset_top = my_nav.offset().top;
+
+ // our function that decides weather the navigation bar should have "fixed" css position or not.
+ var sticky_navigation = function () {
+ var scroll_top = $(window).scrollTop(); // our current vertical position from the top
+
+ // if we've scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative
+ if (scroll_top > sticky_navigation_offset_top) {
+ my_nav.addClass('stick');
+ } else {
+ my_nav.removeClass('stick');
+ }
+ };
+
+ var initio_parallax_animation = function () {
+ $('.parallax').each(function (i, obj) {
+ var speed = $(this).data('parallax-speed');
+ if (speed) {
+ var background_pos = '-' + (window.pageYOffset / speed) + "px";
+ $(this).css('background-position', 'center ' + background_pos);
+ }
+ });
+ }
+
+ // run our function on load
+ sticky_navigation();
+
+ // and run it again every time you scroll
+ $(window).scroll(function () {
+ sticky_navigation();
+ initio_parallax_animation();
+ });
+
+});