File: D:/HostingSpaces/SBogers10/zelfverkopen.komma.pro/resources/assets/js/site/navigationHandler.js
/* ==========================================================================
NavigationHandler handler
========================================================================== */
/**
* Navigation Handler
* Primary usage for mobile NavigationHandler
* Secondary if site used a pop-up/slide-in menu
*/
var NavigationHandler = {
navElement : '',
scrolled : 0,
isActive : false,
// Initialize click event
init : function()
{
// Bind Navigation to Handler
NavigationHandler.navElement = document.getElementById('mobile-navigation');
// Bind clicks to menu button
var menuButton = document.getElementById('menu-trigger');
if(isset(menuButton)){
menuButton.addEventListener('click', function(){
NavigationHandler.open();
});
}
// Bind clicks to sticky menu button
var stickyMenuButton = document.getElementById('sticky-menu-trigger');
if(isset(stickyMenuButton)){
stickyMenuButton.addEventListener('click', function(){
NavigationHandler.open();
});
}
// Bind clicks to menu button
var mobileMenuButton = document.getElementById('mobile-menu-trigger');
if(isset(mobileMenuButton)){
mobileMenuButton.addEventListener('click', function(){
NavigationHandler.open();
});
}
// Bind clicks to sticky menu button
var stickyMenuButton = document.getElementById('sticky-menu-trigger');
if(isset(stickyMenuButton)){
stickyMenuButton.addEventListener('click', function(){
NavigationHandler.open();
});
}
var mobileShade = document.getElementById('mobile-shader');
if(isset(mobileShade)){
mobileShade.addEventListener('click', function () {
NavigationHandler.close();
});
}
var mobileClose = document.getElementById('mobile-close');
if(isset(mobileClose)){
mobileClose.addEventListener('click', function () {
NavigationHandler.close();
});
}
var mobileClose = document.getElementById('mobile-close');
if(isset(mobileClose)){
mobileClose.addEventListener('click', function () {
NavigationHandler.close();
});
}
if(isset(NavigationHandler.navElement)){
setTimeout(function () {
NavigationHandler.navElement.classList.add('allow-animation');
}, 500);
}
},
// Open Navigation
open : function()
{
NavigationHandler.scrolled = window.pageYOffset;
NavigationHandler.navElement.classList.add('active');
NavigationHandler.navElement.classList.add('shader-active');
NavigationHandler.isActive = true;
setTimeout(function(){
document.body.classList.add('preventScroll');
}, 400);
},
// Close Navigation
close : function()
{
NavigationHandler.navElement.classList.remove('active');
NavigationHandler.navElement.classList.remove('shader-active');
NavigationHandler.isActive = false;
document.body.classList.remove('preventScroll');
window.scrollTo(0, NavigationHandler.scrolled);
}
};
NavigationHandler.init();