From 344b1e8dcd075b3ff64fd849b495feb7456168e1 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sat, 3 Feb 2018 19:17:02 -0700 Subject: [PATCH] format and consolidate code in navigation script --- src/js/01-navigation.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/js/01-navigation.js b/src/js/01-navigation.js index 96150a0..c0bb5a9 100644 --- a/src/js/01-navigation.js +++ b/src/js/01-navigation.js @@ -50,9 +50,7 @@ if (currentPageItem) { activateCurrentPath(currentPageItem).forEach(function (itemId) { - if (expandedItems.indexOf(itemId) < 0) { - expandedItems.push(itemId) - } + if (expandedItems.indexOf(itemId) < 0) expandedItems.push(itemId) }) } @@ -81,9 +79,7 @@ } function toggleNavigation (e) { - if (navToggle.classList.contains('is-active')) { - return closeNavigation(e) - } + if (navToggle.classList.contains('is-active')) return closeNavigation(e) document.documentElement.classList.add('is-clipped--nav') navToggle.classList.add('is-active') navContainer.classList.add('is-active') @@ -114,9 +110,7 @@ function getState (component, version) { var data = window.sessionStorage.getItem('nav-state') - if (data) { - return JSON.parse(data) - } + if (data) return JSON.parse(data) } function saveState () { @@ -127,7 +121,6 @@ if (!el) return (parent.scrollTop = scrollPosition) var margin = 10 - var overTheTop = el.offsetTop - scrollPosition < 0 var belowTheBottom = el.offsetTop - scrollPosition + el.offsetHeight > parent.offsetHeight -- 2.11.0