fixed sidenav with closeOnClick enabled
See original GitHub issueSo, currently, if you have a fixed sideNav and you want closeOnClick
“enabled” for your mobile side, you have to add in a work around to make sure that if a user clicks and is on a full desktop version, it doesn’t hide the side nav when it should be fixed.
TLDR; You can’t have closeOnClick
enabled with a fixed side nav
A workaround I created for this is:
// Side Navigation fix
$('.side-nav li a').on('click', function(e) {
windowsize = $(window).width();
if (windowsize < 992) {
$('.button-collapse').sideNav('hide');
}
});
This is probably something to look into since it is useful to have the sidenav close on click on mobile, but stay fixed on desktop screens.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:9
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Fixed SideNav not Compatible with closeOnClick
If you have a fixed SideNav and you initialize it with closeOnClick: true, then clicking an item closes the SideNav. I expected the...
Read more >CloseOnClick property in sideNav should only be ...
Here I have specified 'fixed' style which keeps the sideNav fixed for larger screens and it hides the sideNav for smaller screens. This...
Read more >Disable closing of sideNav when click outside the sideNav
MaterializeCSS doesn't have a built-in method for achieve this task, but you can use a workaround, unbinding the click event from sideNav overlay:...
Read more >The width of your desired sidenav - GWT Material Design
closeOnClick - If clicked on the sidemenu items it will be automatically closed if set ... width="300" m:id="mysidebar" type="FIXED" closeOnClick="false">
Read more >react-pro-sidebar
Start using react-pro-sidebar in your project by running `npm i ... A function that enables you to update the sidebar's collapsed state.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
sorry guys, i tried to hide the navbar afeter click un the links, but doesnt work, Where, i have to put this code.
if (window.matchMedia(“(min-width: 992px)”).matches) { /* the viewport is at least 992 pixels wide / $(‘.button-collapse’).sideNav({ closeOnClick: false, // Closes side-nav on clicks, useful for Angular/Meteor } ); } else { / the viewport is less than 992 pixels wide */ $(‘.button-collapse’).sideNav({ closeOnClick: true, // Closes side-nav on clicks, useful for Angular/Meteor } ); }
i am working with react and materialize.
thanks in advance.
It works! Valeu, parceiro