From fc9401f04a3aca5abb22f87ebc210de8afe11d32 Mon Sep 17 00:00:00 2001 From: marvin-borner@live.com Date: Tue, 10 Apr 2018 21:50:16 +0200 Subject: Initial Commit --- assets/js/main.js | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 assets/js/main.js (limited to 'assets/js/main.js') diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..b9cfe34 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,93 @@ +/****** + GENERAL + ******/ + +/***** + NAVBAR + *****/ +var $el, leftPos, newWidth, + $mainNav = $(".Navbar"); +$mainNav.append(""); +var $magicLine = $(".NavbarLine"); +$magicLine + .css("left", $(".ActiveTab").position().left) + .data("origLeft", $magicLine.position().left) + .data("origWidth", $magicLine.width()); +$(".NavbarIconWrap").on("click", function () { + $(".NavbarIconWrap").removeClass("ActiveTab"); + $(this).addClass("ActiveTab"); + var index = $(this).attr('id'); + $('.MainTabWindows').slick('slickGoTo',index); + //$('.MainTabWindows').flickity().flickity('select', index); + + $el = $(this); + leftPos = $el.position().left; + $magicLine.stop().animate({ + left: leftPos, + width: newWidth, + }, 300); +}); + +/******* +FLICKITY +*******/ +$('.MainTabWindows').slick({ + initialSlide: 2, + mobileFirst: true, + nextArrow: "", + prevArrow: "", + infinite: false, + zIndex: 500 +}); + +$('.MainTabWindows').on('beforeChange', function(event, slick, currentSlide, nextSlide){ + //console.log(nextSlide); + $(".NavbarIconWrap").removeClass("ActiveTab"); + $el = $("#" + nextSlide); + $el.addClass("ActiveTab"); + leftPos = $el.position().left; + $magicLine.stop().animate({ + left: leftPos, + width: newWidth + }, 300); +}); + +/* +$('.MainTabWindows').flickity({ + cellAlign: 'left', + prevNextButtons: false, + pageDots: false, + friction: 0.3, + dragThreshold: ($("body").width() * 0.5), + initialIndex: 2, + wrapAround: true, + maxSwipeWidth: 0, + on: { + change: function (index) { + $(".NavbarIconWrap").removeClass("ActiveTab"); + $el = $("#" + index); + $el.addClass("ActiveTab"); + leftPos = $el.position().left; + $magicLine.stop().animate({ + left: leftPos, + width: newWidth + }, 300); + }, + dragStart: function () { + $(".ActiveTab").css({ transform: 'scale(1.05)' }); + }, + dragEnd: function () { + $(".NavbarIconWrap").css({ transform: 'scale(1.0)' }); + }/*, + scroll: function (event, progress) { + var TotalWidth = $("body").width(); + console.log(progress / 10); + leftPos = ((progress / 1000) * TotalWidth + 'px'); + $magicLine.stop().animate({ + left: leftPos, + width: newWidth + }); + }* + } +}); +*/ \ No newline at end of file -- cgit v1.2.3