Last active
June 24, 2017 07:16
-
-
Save Braunson/6887262 to your computer and use it in GitHub Desktop.
Added close menu option for codrops/SidebarTransitions. Just add closeMenu as the ID to an item in your st-menu container (in your menu)
Thanks @miix -- Updated the Gist.
How can the menu automatically be closed when I click on one of the buttons in menu ?
please help. how to do the same using mousehover instead of click? please help
After some hours I got a solution to close the sidebar with the same button.
I changed
classie.addClass(container, 'st-menu-open');
to
classie.toggleClass(container, 'st-menu-open');
With no effect. Then I changed
container.className = 'st-container';
to
container.id = 'st-container';
Now it works! I can open and close with the same button.
(I made a burger icon)
`buttons.forEach(function(el, i) {
var effect = el.getAttribute('data-effect');
el.addEventListener(eventtype, function(ev) {
ev.stopPropagation();
ev.preventDefault();
container.id = 'st-container'; // ORIGINAL: container.className = 'st-container';
classie.add(container, effect);
setTimeout(function() {
classie.toggleClass(container, 'st-menu-open'); // FIX: Vorher: addClass
}, 25);
document.addEventListener(eventtype, bodyClickFn);
//closeMenu.addEventListener(eventtype, closeMenuClickFn);
});
});`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That script is not working fine on windows phone 8. menu is not getting opened for this. Please suggest. Also that is not working for IE version