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

Issue with fixed header #48

Open
minemindmedia opened this issue Sep 28, 2020 · 4 comments
Open

Issue with fixed header #48

minemindmedia opened this issue Sep 28, 2020 · 4 comments
Labels

Comments

@minemindmedia
Copy link

First of all, thank you for this awesome menu!!!

I am having trouble getting it to work with a fixed header. When opening the menu, I have it set to push the content to the right. It works fine on first page load but if I scroll down and then open the menu, the fixed header disappears. I can't figure out what is causing this to happen. Hope you have a solution, thank you.

@somewebmedia
Copy link
Owner

Can you provide me with some demo so I can check what's happening?

@Phoenixy
Copy link

Hi,
I also saw this happening to me as well, but I think this is the expected behavior, so I have no problems with it.
If you open the menu on the top of the page (without any scrolling), the fixed header won't disappear, but if you scroll down, then open the menu there, the fixed header disappears.
example1
example2

@Exacore
Copy link

Exacore commented Oct 11, 2020

You can try to fix this bug with thoses lines of code (jQuery) :

// Resize
function resize() {
// Sticky Fix
var headerHeight = $('.header').outerHeight();
$('.header').css('position', 'fixed');
$('.header').next().css('margin-top', headerHeight + 'px');
}
window.addEventListener('resize', resize);
resize();

@somewebmedia
Copy link
Owner

Ah I see, when the menu opens, if you have pushContent option enabled, the container element gets transform property which displaces any fixed child element.
Here is the explanation of why that's happening: https://stackoverflow.com/questions/15194313/transform3d-not-working-with-position-fixed-children/15256339#15256339

So a workaround would be something like this:

var $fixed_header = $('#fixed-header'); // your fixed header element
var $container = $('#container'); // element that you've set to pushContent

Nav.on('toggle', function(e, settings) {
  if (e.data.action == 'open') {
    $fixed_header.css('top', -$container.offset().top);
  }
});

Nav.on('close', function(e, settings) {
  $fixed_header.css('top', 0);
});

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

No branches or pull requests

4 participants