Skip to content

Commit

Permalink
feat: Agenda URL #now scroll to current event
Browse files Browse the repository at this point in the history
  • Loading branch information
holloway committed Jul 31, 2024
1 parent 247361b commit a852d9e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions client/agenda/AgendaQuickAccess.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ function scrollToDay (dayId, ev) {
}
function scrollToNow (ev) {
ev.preventDefault()
const lastEventId = agendaStore.findCurrentEventId()
if (lastEventId) {
Expand All @@ -217,6 +215,20 @@ function scrollToNow (ev) {
}
}
/**
* Scrolls to now on page load when browser location hash is "#now"
*/
(function scrollToNowHashInit() {
if (window.location.hash !== "#now") return
const unsubscribe = agendaStore.$subscribe((mutation, agendaStoreState) => {
if (agendaStoreState.schedule.length === 0) {
return
}
scrollToNow()
unsubscribe() // we only need to scroll once, so unsubscribe from future updates
})
})()
</script>
<style lang="scss">
Expand Down

0 comments on commit a852d9e

Please sign in to comment.