$(document).ready(function () { var navbar_menu_mobile_html; var navbar_menu_default_html = $('#menu').html(); $(window).resize(function () { if ($(window).width() <= 1006) { if(!navbar_menu_mobile_html) { $("#menu").mmenu({ extensions: ["position-bottom", "fullscreen", "theme-black", "listview-50", "fx-panels-slide-up", "fx-listitems-drop", "border-offset"], navbar: { title: "" }, }, {}); var API = $("#menu").data( "mmenu" ); $(".mmenu__link").click(function() { API.close(); }); $(".mh-head.mm-sticky").mhead({ scroll: false }); $(".mh-head:not(.mm-sticky)").mhead({ scroll: false }); } navbar_menu_mobile_html = $('#menu').html(); $('#my-menu').html(navbar_menu_mobile_html); } else { $('#my-menu').html(navbar_menu_default_html); } }).resize(); }); $(document).scroll(function (e) { var scrollTop = $(document).scrollTop(); if (scrollTop > 0) { $('header').addClass('scrolled'); } else { $('header').removeClass('scrolled'); } }); var $headerHeight = $('.header').innerHeight(); $(document).ready(function () { $(".mm-menu").css("cssText", `height: calc(100% - ${$headerHeight}px) !important;`); }); $(window).scroll(function () { var $headerScrollHeight = $('.header').innerHeight(); if ($(this).scrollTop() === 0) { $(".mm-menu").css("cssText", `height: calc(100% - ${$headerHeight}px) !important;`); } else { $(".mm-menu").css("cssText", `height: calc(100% - ${$headerScrollHeight}px) !important;`); } }); //Nadanie klasy active w menu var sections_offset = []; $(document).scroll(function (e) { var scrollTop = $(document).scrollTop(); mark_as_active_nav(scrollTop); }); var id_el; function mark_as_active_nav(offset) { //tworzenie tablicy z odlelosciami sekcji menu $('.mmenu__item a[data-scroll]').each(function (i) { var navbar_height = $('header').height(); var id_element = $(this).attr('data-scroll'); var offset_element = ($('#' + id_element).offset().top - navbar_height) - 50; offset_element = offset_element < 0 ? 0 : offset_element; sections_offset[i] = [id_element, offset_element]; }); var id_el; //sprawdzam odleglosci $(sections_offset).each(function (i) { var offset_el = sections_offset[i][1]; if (offset_el <= offset) { id_el = sections_offset[i][0]; return; } }) //oznaczam menu $('.mmenu__item').removeClass('active'); $('.mmenu__item a[data-scroll=' + id_el + ']').closest('li').addClass('active'); } //SmoothScroll var $navbar_height = 118; if ($(window).width() <= 440) { $navbar_height = 100; } $(document).on('click', 'a[href^="#"]', function (event) { event.preventDefault(); $('html, body').animate({ scrollTop: $($.attr(this, 'href')).offset().top - $navbar_height + 10 }, 800); });