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

Smooth scroll breaks with MeanMenu #34

Closed
amityweb opened this issue Apr 28, 2014 · 2 comments
Closed

Smooth scroll breaks with MeanMenu #34

amityweb opened this issue Apr 28, 2014 · 2 comments

Comments

@amityweb
Copy link

I dont know why but smooth scroill breaks when using Mean menu. this is the code:

  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var header_height = $('#header').height();
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top - header_height
        }, 500, 'easeInOutCubic');
        return false;
      }
    }
  });

We fix the header position, and need to scroll to a position minus the header position, but this whole function does not work with mean menu.

Maybe I need to rebind the click function to mean menu, but is there some afterMenmenu function we can call?

Thanks

@meanthemes
Copy link
Owner

I think its probably the preventDefault on the click, no there is no after function so rebinding is your best option.

@amityweb
Copy link
Author

Ah thats probably it.

I decided to not have the scrolling option on mobile, but our main issue was needing to offset the position of the jumped to anchor by the height of the fixed header.

So instead I added a class to the anchor links, then in the mobile stylesheet put a margin top on the anchors the same height as the header, so now when it jumps down it positions correctly at the anchor.

So its a workaround which I think acceptable.

Thanks

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

2 participants