Skip to content

Commit

Permalink
Fix nav not scrolling to correct position
Browse files Browse the repository at this point in the history
  • Loading branch information
mvsde committed Feb 14, 2019
1 parent 5a28483 commit 03e3344
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ui/js/components/nav.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const nav = document.querySelector('.js-nav')
const storageKey = 'pangolinNavScrollPosition'
const STORAGE_KEY = 'pangolinNavScrollPosition'

window.addEventListener('DOMContentLoaded', () => {
nav.scrollTop = localStorage.getItem(storageKey)
window.addEventListener('load', () => {
nav.scrollTop = localStorage.getItem(STORAGE_KEY)
})

window.addEventListener('beforeunload', () => {
localStorage.setItem(storageKey, nav.scrollTop)
localStorage.setItem(STORAGE_KEY, nav.scrollTop)
})
3 changes: 1 addition & 2 deletions ui/templates/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
<link rel="shortcut icon" href="{% static project.branding.favicon %}">
{% endif %}

<link rel="stylesheet" href="{% static 'pangolin/styles.css' %}">

{% if websocket.port %}
<script>var websocketPort = {{ websocket.port }}</script>
{% endif %}

<script defer src="{% static 'pangolin/scripts.js' %}"></script>
<link rel="stylesheet" href="{% static 'pangolin/styles.css' %}">

{% if project.branding -%}
<style>
Expand Down

0 comments on commit 03e3344

Please sign in to comment.