/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var sections_offset = [];
$(document).scroll(function (e)
{
var scrollTop = $(document).scrollTop();
if (scrollTop > 0)
{
$('header').addClass('scrolled');
} else
{
$('header').removeClass('scrolled');
}
//zaznaczanie menu
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');
}
function scroll_to_div(id)
{
var navbar_height = $('header').height();
$("html, body").animate({
scrollTop: $('#' + id).offset().top - navbar_height
}, 1000);
}
//scrolloanie
$('a[data-scroll]').click(function (e)
{
e.preventDefault();
var scroll_to_id = $(this).attr('data-scroll');
scroll_to_div(scroll_to_id);
});
$(document).ready(function ()
{
// rozwijane menu - mobile, hamburger
$(window).resize(function ()
{
if ($(window).width() <= 1006)
{
$("#my-menu").mmenu({
extensions: ["fullscreen", "theme-black", "listview-large", "fx-panels-slide-up", "fx-listitems-drop", "border-offset"],
offCanvas: {
position: "bottom",
zposition: "front"
},
navbar: {
title: ""
},
navbars: [{
content: [
// '',
// '',
// '