negomi / react-burger-menu

:hamburger: An off-canvas sidebar component with a collection of effects and styles using CSS transitions and SVG path animations
http://negomi.github.io/react-burger-menu/
MIT License
5.05k stars 586 forks source link

Squeeze main content when sidebar is toggled #475

Closed archiif closed 1 year ago

archiif commented 2 years ago

Instead of overlaying the menu over the main content, is there a way to have it so that the width of the main content gets squeezed accordingly as the sidebar unfolds?

Something like this: image

Push is pretty close, but unfortunately that simply pushes the content which can potentially send it partially offscreen. Scale is also close, but it resizes both the width and height. Also, it seems that the main content's alignment with the sidebar isn't particularly exact (unlike Push).

Any help would be appreciated.

archiif commented 2 years ago

Came up with this for now:

import menuFactory from '../node_modules/react-burger-menu/lib/menuFactory';

const styles = {
  pageWrap(isOpen, width, right) {
    return {
      [`margin-${right ? "right" : "left"}`]: isOpen ? '' : width,
      transition: 'all 0.5s'
    }
  },

  outerContainer(isOpen) {
    return {
      overflow: isOpen ? '' : 'hidden'
    };
  }
};

export const squeeze = menuFactory(styles)

It would be nice to see this API exposed in a cleaner fashion, they really help improve customizability.

Lokeshkhati commented 2 years ago

Hey @archiif, I would love to contribute to it,

would you mind to assign it to me?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.