Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable/hide sidebar at onload #442

Closed
initbar opened this issue Apr 2, 2018 · 4 comments
Closed

disable/hide sidebar at onload #442

initbar opened this issue Apr 2, 2018 · 4 comments

Comments

@initbar
Copy link

initbar commented Apr 2, 2018

Is there an option to hide or disable sidebar at onload event? I'm currently relying on custom $('.sidebar-toggle-button').click() to hide it, but wondering if there is native support or options.

@Spencer-Scorcelletti-CK

I think <body class="close"> will work

@initbar initbar closed this as completed Apr 10, 2018
@xcorpio
Copy link

xcorpio commented May 16, 2018

hi, this will not work on mobile browser

@Spencer-Scorcelletti-CK

Interesting, how does closing the sidebar work on mobile?

@shawntabrizi
Copy link

shawntabrizi commented Jan 31, 2020

The problem here is that the close class has overall strange behavior.

On a mobile screen the close class actually opens the sidebar, while omitting it closes it.

This seems to be some hack to transition a responsive desktop site which has a sidebar to a mobile width and auto-closing the sidebar. However, this transition does not happen by using the close class correctly...

EDIT:

The solution is to add the following styles, which makes consistent close class behavior on mobile and desktop:

/* Fix `close` style on mobile */
@media screen and (max-width: 768px) {
  /* Fix behavior for when sidebar should be open */
  body .sidebar {
    transform: translateX(300px);
  }
  body .content {
    transform: translateX(300px);
  }
  .sidebar-toggle {
    background-color: rgba(255,255,255,0.8);
    transition: 1s background-color;
    width: 284px;
    padding: 10px;
  }

  /* Fix behavior for when sidebar should be closed */
  body.close .sidebar {
    transform: translateX(0);
  }
  body.close .content {
    transform: translateX(0px);
  }
  body.close .sidebar-toggle {
    background-color: transparent;
    width: auto;
    padding: 30px 30px 10px 10px;
  }
}

Note that this does have a strange behavior when actively changing the resolution of your screen, you will see a CSS transition. If someone knows how to fix this, without disabling the transition altogether, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants