Skip to content

Instantly share code, notes, and snippets.

@wplit
Created November 15, 2020 23:27
Show Gist options
  • Select an option

  • Save wplit/04e1d80fdb0e2abe36a17395ae3f2159 to your computer and use it in GitHub Desktop.

Select an option

Save wplit/04e1d80fdb0e2abe36a17395ae3f2159 to your computer and use it in GitHub Desktop.
allow hashlink inside one offcanvas make sure the second one is also closed
jQuery(document).ready(function($) {
// Change these selectors to match the class or ID of your offcanvas elements
let mainOffcanvas = '.main-offcanvas',
secondOffcanvas = '.second-offcanvas';
// Make sure second offcanvas is closed
$(mainOffcanvas).find('a[href*=\\#]').not(".menu-item-has-children > a").on('click', function(e) {
e.stopPropagation();
if (this.pathname === window.location.pathname) {
$(secondOffcanvas).removeClass('oxy-off-canvas-toggled');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment