// =============================================================================
// Navbar
// =============================================================================

;((window) => {

	'use strict';

	const Navbar = (config) => {

		const navbar = {
			props: Object.assign({
				target: ".navbar--hiding",
				class: "is--hidden",
				delta: 50
			}, config),
			state: {
				element: null,
				bottom: null,
				scrollTop: null,
				lastScrollTop: 0
			},
			init() {
				if (this.state.element = document.querySelector(this.props.target)) {
					this.state.bottom = document.body.clientHeight - window.innerHeight;
					document.addEventListener('scroll', tools.throttle((e) => {
						this.handleScroll();
					}, 250));
				} else {
					return;
				}
			},
			handleScroll() {
				console.log("handledScroll");
				this.state.scrollTop = window.pageYOffset | document.body.scrollTop;
				if (Math.abs(this.state.lastScrollTop - this.state.scrollTop) <= this.props.delta) {
					return;
				} else {
					if (this.state.scrollTop > (this.state.bottom - this.props.delta) 
						|| this.state.scrollTop <= 0 
						|| this.state.scrollTop < this.state.lastScrollTop) {
						this.showNavbar();
					} else if (this.state.scrollTop > this.state.lastScrollTop) {
						this.hideNavbar();
					}
				}
				this.state.lastScrollTop = this.state.scrollTop;
			},
			hideNavbar() {
				this.state.element.classList.add(this.props.class);
			},
			showNavbar() {
				this.state.element.classList.remove(this.props.class);
			}
		}

		return navbar;
	};

	window.Navbar = Navbar;
	
})(window);



@@ -299,24 +299,82 @@
 vbar
+%22,%0A%09%09%09%09toggle: %22.navbar__toggle%22,%0A%09%09%09%09hidingClass: %22is
 --hid
-ing
+den
 %22,%0A%09%09%09%09
-c
+openC
 lass
@@ -376,30 +376,69 @@
 Class: %22is--
-hidden
+open%22,%0A%09%09%09%09highlightClass: %22burger--highlight
 %22,%0A%09%09%09%09delta
@@ -484,24 +484,42 @@
 ment: null,%0A
+%09%09%09%09toggle: null,%0A
 %09%09%09%09bottom: 
@@ -654,24 +654,93 @@
 .target)) %7B%0A
+%09%09%09%09%09if (this.state.element.classList.contains('navbar--hiding')) %7B%0A%09
 %09%09%09%09%09this.st
@@ -801,16 +801,17 @@
 Height;%0A
+%09
 %09%09%09%09%09doc
@@ -869,24 +869,25 @@
  =%3E %7B%0A%09%09%09%09%09%09
+%09
 this.handleS
@@ -891,24 +891,25 @@
 leScroll();%0A
+%09
 %09%09%09%09%09%7D, 250)
@@ -911,16 +911,209 @@
  250));%0A
+%09%09%09%09%09%7D%0A%09%09%09%09%09if (this.state.toggle = this.state.element.querySelector(this.props.toggle)) %7B%0A%09%09%09%09%09%09this.state.toggle.addEventListener('click', (e) =%3E %7B%0A%09%09%09%09%09%09%09this.handleClick();%0A%09%09%09%09%09%09%7D)%0A%09%09%09%09%09%7D%0A
 %09%09%09%09%7D el
@@ -1166,42 +1166,8 @@
 ) %7B%0A
-%09%09%09%09console.log(%22handledScroll%22);%0A
 %09%09%09%09
@@ -1765,33 +1765,39 @@
 .add(this.props.
-c
+hidingC
 lass);%0A%09%09%09%7D,%0A%09%09%09
@@ -1862,17 +1862,178 @@
 s.props.
-c
+hidingClass);%0A%09%09%09%7D,%0A%09%09%09handleClick() %7B%0A%09%09%09%09this.state.toggle.classList.toggle(this.props.highlightClass);%0A%09%09%09%09this.state.element.classList.toggle(this.props.openC
 lass);%0A%09

add mobile trigger to navbar.vanilla.js