(function ($) { "use strict"; $(document).ready(function () { FullPageInit(); handleNavigationNextPrev(); ScrollToSection(); accordion(); handleScrollBackUp(); }); /** * Activate plans details on mobile */ const FullPageInit = () => { $('#fullpage').fullpage({ licenseKey: '1LHKK-U0RE8-K703H-MSJ8J-MXRON', anchors: ['Pirmas', 'Antras', 'Trecias'], menu: '#fp-labas-navigation', responsiveWidth: 767, responsiveHeight: 525, verticalCentered: false, credits: { enabled: false}, scrollingSpeed: 1000, css3:false, afterLoad: function(section, origin){ let activeSection = section.index; let originSection = origin.index; if ( originSection == 2 ) { $('.labas-navigation').addClass('reverse'); } else { $('.labas-navigation').removeClass('reverse'); } } }); } /** * Handle slide navigation with arrow */ const handleNavigationNextPrev = () => { const button = $('.labas-navigation-item--last'); button.on('click', function() { let activeSection = $.fn.fullpage.getActiveSection().index(); if ( activeSection == 0) { $.fn.fullpage.moveSectionDown(); } else if ( activeSection == 1 ) { $.fn.fullpage.moveSectionDown(); } else { $.fn.fullpage.moveSectionUp(); } }) } /** * Handle slide change on scroll back up of overlowed section */ const handleScrollBackUp = () => { //Timeout for overflow div to be inicialized by fullpageJs setTimeout(() => { const scrollable = $('.duk-section .fp-overflow'); if ( scrollable.length > 0 ) { $(scrollable).on('scroll', function(ev) { const scrollPosition = $(this).scrollTop(); if (scrollPosition === 0) { $.fn.fullpage.moveSectionUp(); } }) } }, "1000") } /** * Activate terms more button */ const accordion = () => { $('.duk-list_item').click(function() { $(this).toggleClass('toggle'); $(this).next().slideToggle(); }); } /** * Scroll to section */ const ScrollToSection = () => { $('a.scroll-to[href^="#"]').on('click',function (e) { e.preventDefault(); var target = this.hash; var $target = $(target); $('html, body').stop().animate({ scrollTop: $target.offset().top - 100 }, 700); return false; }); } })(jQuery);