tabvengers / spicy-sections

Creative Commons Zero v1.0 Universal
128 stars 10 forks source link

Honour fragment link on nav and hashchange #17

Closed hidde closed 2 years ago

hidde commented 2 years ago

I've added some code that opens section content when page opens with hash or when the hash changes (fixes #3).

This works both if:

Demo here: https://codepen.io/hidde/pen/RwZbgVK

One weird thing: in Firefox, the location.hash change only works if wrapped in setTimeout (1 millisecond works 🤷🏻‍♂️); in Chromium this hack is not required.