Skip to content

Commit

Permalink
Close onPageNav, when after navigation on mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepWalker committed Jun 6, 2018
1 parent 852f1fc commit 4ee2751
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/core/nav/SideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ class SideNav extends React.Component {
<script
dangerouslySetInnerHTML={{
__html: `
(function() {
document.addEventListener('DOMContentLoaded', function() {
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
createToggler('#tocToggler', 'body', 'tocActive');
const headings = document.querySelector('.toc-headings');
headings && headings.addEventListener('click', function(event) {
if (event.target.tagName === 'A') {
document.body.classList.remove('tocActive');
}
}, false);
function createToggler(togglerSelector, targetSelector, className) {
var toggler = document.querySelector(togglerSelector);
var target = document.querySelector(targetSelector);
Expand All @@ -53,7 +60,7 @@ class SideNav extends React.Component {
target.classList.toggle(className);
};
}
}());
});
`,
}}
/>
Expand Down

0 comments on commit 4ee2751

Please sign in to comment.