Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Highlight anchors in the page contents navigation, on scroll #61

Merged
merged 10 commits into from
Oct 27, 2016

Commits on Oct 25, 2016

  1. Include javascript for the sticky page contents

    This already exists within the frontend toolkit, use both stick at top
    when scrolling (to set the page contents to position:fixed) and stop
    scrolling at footer, to return the page contents to position: static
    when the top of the footer reaches the bottom of the page contents.
    gemmaleigh committed Oct 25, 2016
    Configuration menu
    Copy the full SHA
    e6eedf6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0adf211 View commit details
    Browse the repository at this point in the history
  3. Add js hooks for StickAtTopWhenScrolling and HighlightActiveSection

    The navigation highlight module uses this hook for the
    in-page navigation (js-page-contents).
    
    Also add a js hook to the page contents area
    This is required to get the stick-at-top-when-scrolling js to work.
    
    Stick at top when scrolling also has a futher optional hook to set the
    sticky element and the shim to resize to fit the parent (the hook for this is js-sticky-resize).
    gemmaleigh committed Oct 25, 2016
    Configuration menu
    Copy the full SHA
    f1a83a8 View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2016

  1. Include styles required by the stick at top when scrolling js

    These are required by GOVUK.stickAtTopWhenScrolling.
    
    Add extra padding on to the bottom of the page contents list, so that
    it doesn’t allow the Is there anything wrong with this page? link to
    overlap the bottom of the page contents list.
    gemmaleigh committed Oct 26, 2016
    Configuration menu
    Copy the full SHA
    cd515b0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    241dace View commit details
    Browse the repository at this point in the history
  3. Add a new module - highlight active section heading

    When the page is scrolled, this will highlight an item in the left hand page contents.
    gemmaleigh committed Oct 26, 2016
    Configuration menu
    Copy the full SHA
    367b8b6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    56a0d0e View commit details
    Browse the repository at this point in the history
  5. Add a spec to check that:

    - it has no highlighted nav items, when the page loads
    - it highlights a nav item, when the page is scrolled
    
    Mock the values for scroll position and heading position, and also
    footer position to ensure the last item is highlighted.
    gemmaleigh committed Oct 26, 2016
    Configuration menu
    Copy the full SHA
    56f7080 View commit details
    Browse the repository at this point in the history
  6. Handle cases where the headings do not appear on the page

    The body of a guide is rendered using a shared ‘GovSpeak’ component.
    
    In test mode shared components are not fetched from Static. Instead they are rendered as a dummy tag which contains a JSON dump of the locals - the arguments passed to the component.
    
    This means that the headings we expect to be present on the page (within the body of the guide) are not present. This which was causing JavaScript errors on the page, which were appearing in unrelated tests that used the Javascript driver to execute.
    
    By returning early if we cannot get the offset of a heading we guard against this.
    36degrees authored and gemmaleigh committed Oct 26, 2016
    Configuration menu
    Copy the full SHA
    cff0bdd View commit details
    Browse the repository at this point in the history
  7. Adjust margins for govspeak content

    This is so that when a page contents anchor is clicked on, the title
    “Page contents” and the title of the section will line up - rather than
    the title of the section sitting at the very top of the page.
    gemmaleigh committed Oct 26, 2016
    Configuration menu
    Copy the full SHA
    df4b873 View commit details
    Browse the repository at this point in the history