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

H2 scrolling bug and suggested fix #185

Closed
mickschonhut opened this issue Apr 4, 2019 · 1 comment
Closed

H2 scrolling bug and suggested fix #185

mickschonhut opened this issue Apr 4, 2019 · 1 comment

Comments

@mickschonhut
Copy link

Anytime the user scrolls past a header deeper than a H2, the highlighting on the left hand Nav jumps to the parent heading.

This wasn't fixed by Release 1.8.0.

Below is a diff against the alphagov/govuk_tech_docs of a simple fix we developed for this, if you'd like to adopt it.

diff --git a/lib/assets/javascripts/_modules/in-page-navigation.js b/lib/assets/javascripts/_modules/in-page-navigation.js
index e945023..951a058 100644
--- a/lib/assets/javascripts/_modules/in-page-navigation.js
+++ b/lib/assets/javascripts/_modules/in-page-navigation.js
@@ -121,7 +121,7 @@

var $this = $(this);

  • if (Math.floor($this.position().top) <= 0) {
  • if (Math.floor($this.position().top) <= 0 && $tocItems.filter('a[href$="#' + $this.attr('id') + '"]').length > 0) {
    result = $this;
    }
    });
@NickColley
Copy link

Thanks for raising, this is a duplicate of alphagov/tech-docs-gem#142 so I'll close this out and you can follow along in that issue. :)

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