Skip to content

Commit 03b30d0

Browse files
committed
scroll to active
1 parent 499ec8a commit 03b30d0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/components/TalkItem.vue

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<article class="event mb-medium p-medium pt-none" :class="event.submission_type.en === 'Break' && 'break'">
2+
<article class="event mb-medium p-medium pt-none" :class="event.submission_type.en === 'Break' && 'break'" ref="el">
33
<div class="pt-xsmall pb-2xsmall flex between" style="margin-left: -0.75rem">
44
<div v-if="event.submission_type.en !== 'Break'" class="badge h-fit">
55
<template v-if="!event.submission_type.en.includes('Workshop')">
@@ -46,9 +46,9 @@
4646
</template>
4747

4848
<script setup lang="ts">
49-
import { format, differenceInMinutes } from 'date-fns';
49+
import { format, differenceInMinutes, isWithinInterval } from 'date-fns';
5050
import { renderMarkdown } from 'Content/renderContent';
51-
import { type PropType } from 'vue'
51+
import { onMounted, ref, type PropType } from 'vue'
5252
import type { PretalxEvent, Break, BreakParsed } from '@/types/pretalx';
5353
import SpeakerItem from './SpeakerItem.vue'
5454
import LinkIcon from './icons/LinkIcon.vue'
@@ -71,6 +71,12 @@ const getSlug = (event: PretalxEvent) => {
7171
return `online-${event.title.replace(/[ ]/g, '-').replace(/[^a-zA-Z0-9-]/g, '').toLowerCase()}`
7272
}
7373
74+
const el = ref(null);
75+
const isOngoing = isWithinInterval(new Date(), { start: new Date(props.event.slot.start), end: new Date(props.event.slot.end) })
76+
onMounted(() => {
77+
if (isOngoing) el.value?.scrollIntoView();
78+
});
79+
7480
</script>
7581

7682
<style scoped>

0 commit comments

Comments
 (0)