audiobookshelf/client/components/player/TranscriptionLine.vue

44 lines
786 B
Vue
Raw Normal View History

2024-05-04 11:00:30 +01:00
<template>
2024-05-04 12:21:07 +01:00
<div :class="{ 'text-warning': isActive }" class="cursor-pointer" @click.stop="clickSeek">
2024-05-04 11:00:30 +01:00
<div v-html="cue.text"></div>
</div>
</template>
<script>
export default {
props: {
cue: VTTCue
},
data() {
return {
isActive: false
};
},
2024-05-04 12:21:07 +01:00
methods: {
clickSeek() {
const time = this.cue.startTime
this.$emit('seek', time)
},
scrollIntoView() {
this.$el.scrollIntoView({behavior: 'smooth'})
}
},
mounted() {
if (this.isActive) {
this.scrollIntoView()
2024-05-04 12:21:07 +01:00
}
},
2024-05-04 11:00:30 +01:00
created() {
this.cue.onenter = () => (this.isActive = true)
this.cue.onexit = () => (this.isActive = false)
2024-05-04 11:00:30 +01:00
},
watch: {
isActive(newVal) {
if (newVal) {
this.scrollIntoView()
2024-05-04 11:00:30 +01:00
}
}
}
};
</script>