diff --git a/src/js/menutoggle.js b/src/js/menutoggle.js
index d0e64538..a0ce99de 100644
--- a/src/js/menutoggle.js
+++ b/src/js/menutoggle.js
@@ -1,4 +1,5 @@
// Grab any element that has the 'js-toggle' class and add an event listner for the toggleClass function
+var bodyScrollLock = require('body-scroll-lock');
var toggleBtns = document.getElementsByClassName('js-toggle')
for (var i = 0; i < toggleBtns.length; i++) {
toggleBtns[i].addEventListener('click', toggleClass, false)
@@ -11,21 +12,29 @@ function toggleClass() {
var mobileCurrentlyOpen = document.querySelector('.mobilemenu:not(.dn)')
var desktopCurrentlyOpen = document.querySelector('.desktopmenu:not(.dn)')
var desktopActive = document.querySelector('.desktopmenu:not(.dn)')
-
+ var mobileWillOpen = false
// Loop through the targets' divs
for (var i = 0; i < content.length; i++) {
var matches = document.querySelectorAll(content[i]);
//for each, if the div has the 'dn' class (which is "display:none;"), remove it, otherwise, add that class
[].forEach.call(matches, function(dom) {
- dom.classList.contains('dn') ?
- dom.classList.remove('dn') :
- dom.classList.add('dn');
+ if (dom.classList.contains('dn')) {
+ dom.classList.remove('dn')
+ if (dom.classList.contains("mobilemenu")){
+ // disable body scroll so this menu may scroll on ios.
+ bodyScrollLock.disableBodyScroll(dom)
+ mobileWillOpen = true
+ }
+ } else {
+ dom.classList.add('dn')
+ }
return false;
});
// close the currently open menu items
if (mobileCurrentlyOpen) mobileCurrentlyOpen.classList.add('dn')
if (desktopCurrentlyOpen) desktopCurrentlyOpen.classList.add('dn')
if (desktopActive) desktopActive.classList.remove('db')
-
}
+ if (!mobileWillOpen) bodyScrollLock.clearAllBodyScrollLocks()
}
+
diff --git a/src/package.json b/src/package.json
index 04bd261f..5b5dcf81 100644
--- a/src/package.json
+++ b/src/package.json
@@ -32,5 +32,7 @@
"tachyons": "^4.7.0",
"webpack": "^2.3.3"
},
- "dependencies": {}
+ "dependencies": {
+ "body-scroll-lock": "^2.5.7"
+ }
}