function initAlux(){ function toggleClass(element, className){ if (!element || !className){ return; } var classString = element.className, nameIndex = classString.indexOf(className); if (nameIndex == -1) { classString += ' ' + className; } else { classString = classString.substr(0, nameIndex-1) + classString.substr(nameIndex+className.length); } element.className = classString; } // Menu Toggle var toggle = document.getElementsByClassName('toggler'); for (var i=0; i < toggle.length; i++){ toggle[i].addEventListener('click', function() { //first parameter trigger second the element to toggle the class toggleClass(this, 'x'); var menuId = this.attributes["data-target"].value; toggleClass(document.getElementById(menuId), 'open'); }); } // Dropdown Menu var dropdown = document.querySelectorAll('.dropdown'); var dropdownArray = Array.prototype.slice.call(dropdown,0); dropdownArray.forEach(function(el){ var button = el.querySelector('a[data-toggle="dropdown"]'), menu = el.querySelector('.dropdown-menu'); button.addEventListener('click', function(e) { if( menu.className == 'dropdown-menu') { // remove all classes for (var i=0; i < dropdownArray.length; i++){ dropdownArray[i].querySelector('.dropdown-menu').className = 'dropdown-menu'; dropdownArray[i].querySelector('a[data-toggle="dropdown"]').className = ''; } // add classes to current item menu.className = 'dropdown-menu open'; button.className = 'select'; e.preventDefault(); } else { // close current item menu.className = 'dropdown-menu'; button.className = ''; e.preventDefault(); } }); }); } initAlux(); /* Scroll animation */ const scrollTo = function({target, duration = 300, callback} = {}){ if(!target){ console.error('scrollTo() => You must specify a target.') return false } const targetHref = target.getAttribute('href').replace( /^#/ , '') const destination = document.getElementById(targetHref) const start = window.pageYOffset const startTime = 'now' in window.performance ? performance.now() : new Date().getTime() const documentHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight) const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight const destinationOffset = typeof destination === 'number' ? destination : destination.offsetTop const destinationOffsetToScroll = Math.round(documentHeight - destinationOffset < windowHeight ? documentHeight - windowHeight : destinationOffset) if('requestAnimationFrame' in window === false) { window.scroll(0, destinationOffsetToScroll) if(callback) { callback() } return } const scroll = function() { const now = 'now' in window.performance ? performance.now() : new Date().getTime() const time = Math.min(1, ((now - startTime) / duration)) window.scroll(0, Math.ceil((time * (destinationOffsetToScroll - start)) + start)) if(time >= 1 || Math.round(window.pageYOffset) === destinationOffsetToScroll) { if(callback) { callback() } return } requestAnimationFrame(scroll) } requestAnimationFrame(scroll) }; const navLink = Array.from(document.querySelectorAll('.scroll')) navLink.forEach(el => { el.addEventListener('click', function(ev) { ev.preventDefault() ev.stopPropagation() scrollTo({ duration: 300, target: ev.target }); }) }) /* Animation on scroll with sal.j-scroll https://mciastek.github.io/sal/ */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.sal=t():e.sal=t()}(this,(function(){return(()=>{"use strict";var e={855:(e,t,n)=>{function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;tw});var s="Sal was not initialised! Probably it is used in SSR.",i="Your browser does not support IntersectionObserver!\nGet a polyfill from here:\nhttps://github.com/w3c/IntersectionObserver/tree/master/polyfill",l={rootMargin:"0% 50%",threshold:.5,animateClassName:"sal-animate",disabledClassName:"sal-disabled",enterEventName:"sal:in",exitEventName:"sal:out",selector:"[data-sal]",once:!0,disabled:!1},c=[],u=null,d=function(e){e&&e!==l&&(l=o(o({},l),e))},f=function(e){e.classList.remove(l.animateClassName)},b=function(e,t){var n=new CustomEvent(e,{bubbles:!0,detail:t});t.target.dispatchEvent(n)},p=function(){document.body.classList.add(l.disabledClassName)},m=function(){u.disconnect(),u=null},v=function(){return l.disabled||"function"==typeof l.disabled&&l.disabled()},y=function(e,t){e.forEach((function(e){var n=e.target,r=void 0!==n.dataset.salRepeat,o=void 0!==n.dataset.salOnce,a=r||!(o||l.once);e.intersectionRatio>=l.threshold?(function(e){e.target.classList.add(l.animateClassName),b(l.enterEventName,e)}(e),a||t.unobserve(n)):a&&function(e){f(e.target),b(l.exitEventName,e)}(e)}))},O=function(){p(),m()},h=function(){document.body.classList.remove(l.disabledClassName),u=new IntersectionObserver(y,{rootMargin:l.rootMargin,threshold:l.threshold}),(c=[].filter.call(document.querySelectorAll(l.selector),(function(e){return!function(e){return e.classList.contains(l.animateClassName)}(e,l.animateClassName)}))).forEach((function(e){return u.observe(e)}))},g=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m(),Array.from(document.querySelectorAll(l.selector)).forEach(f),d(e),h()};const w=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l;if(d(e),"undefined"==typeof window)return console.warn(s),{elements:c,disable:O,enable:h,reset:g};if(!window.IntersectionObserver)throw p(),Error(i);return v()?p():h(),{elements:c,disable:O,enable:h,reset:g}}}},t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}return n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(855)})().default})); sal({ selector: ".animate", threshold: 0.3, });