olefredrik / FoundationPress

FoundationPress is a WordPress starter theme based on Foundation 6 by Zurb
https://foundationpress.olefredrik.com
MIT License
2.71k stars 869 forks source link

Linking to an anchor tag on different post/page prevents scrolling up #887

Closed ehrhino closed 7 years ago

ehrhino commented 8 years ago

Can't find anything about this online or the general Foundation docs, so wondering if anyone here has run into this/has ideas on how this can be fixed.

How can this bug be reproduced?

  1. Go to [http://x.red-rhino.com/csi/support-wellness/food-support/#food-bank]
  2. Try and scroll up.

This happens anywhere there is a link going to an anchor tag on another page or post. The above is just an example.

What did you expect to happen? You should be able to scroll up to see the above content, etc as a normal page would function. I'm guessing that this has something to do with how foundationpress sizes the page to fit the window. No idea, though. Issue does not occur when linking to an anchor tag on the same page.

I am using a js snippet to smooth scroll to anchor tags, but I've commented that out and the issue still persists. I'll include it though in case.

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

Thanks for any help you all can offer!

Please List the Following:

colin-marshall commented 8 years ago

@ehrhino try removing the "sticky" behavior from the menu and see if that changes anything.

ehrhino commented 8 years ago

@colin-marshall Just tried that, but to no avail. Here's what it is: $(window).scroll(function() { if ($(this).scrollTop() > 1){ $('#site-navigation').addClass("sticky"); $('.pre-nav').slideUp(400); } else{ $('#site-navigation').removeClass("sticky"); $('.pre-nav').slideDown(400); } });

I also tried commenting out the stickyfooter.js , but that didn't work either :/

colin-marshall commented 8 years ago

@ehrhino try removing all custom JS and also remove all the html markup that has to do with sticky.

ehrhino commented 8 years ago

@colin-marshall
I removed all custom JS, and the nav bar completely, but still nothing. However, when I commented out:

<?php if ( get_theme_mod( 'wpt_mobile_menu_layout' ) == 'offcanvas' ) : ?>
    <div class="off-canvas-wrapper">
        <div class="off-canvas-wrapper-inner" data-off-canvas-wrapper>
            <?php get_template_part( 'template-parts/mobile-off-canvas' ); ?>
<?php endif; ?>

and it's closing tags in footer.php then the issue was solved...leading me to believe it's something with the off-canvas js (which I use for the mobile menu).

colin-marshall commented 8 years ago

Good find! I will see if there are any similar bug reports in Foundation.

ehrhino commented 8 years ago

@colin-marshall any luck? Did some poking around myself, but couldn't find anything.

olefredrik commented 7 years ago

I'm unable to reproduce this error. Is this still an issue? If yes, can you please try to reproduce with the latest version of FoundationPress (it has been updated to use Foundation 6.4.1). If no, can you please close the issue? :)