back

Use # links with transitions

Scroll value is reset during page transition, preventing # links to work by default. To fix that, you can use the following snippet that manually scroll to the target position after a transition.

luge.lifecycle.add('pageIn', navigateToTarget)

function navigateToTarget (done) {
  const hash = window.location.hash
  if (hash) {
    const target = document.querySelector(hash)
    if (target) {
      window.scrollTo(0, target.getBoundingClientRect().top + window.unifiedScrollTop)
    }
  }

  done()
}