Automatically scrolls to active cue when enable/disable the transcription panel

This commit is contained in:
mfcar 2024-05-04 12:52:04 +01:00
parent ee8e7cf958
commit 282203a30a
No known key found for this signature in database

View file

@ -16,18 +16,26 @@ export default {
}, },
methods: { methods: {
clickSeek() { clickSeek() {
const time = this.cue.startTime; const time = this.cue.startTime
this.$emit('seek', time); this.$emit('seek', time)
},
scrollIntoView() {
this.$el.scrollIntoView({behavior: 'smooth'})
}
},
mounted() {
if (this.isActive) {
this.scrollIntoView()
} }
}, },
created() { created() {
this.cue.onenter = () => (this.isActive = true); this.cue.onenter = () => (this.isActive = true)
this.cue.onexit = () => (this.isActive = false); this.cue.onexit = () => (this.isActive = false)
}, },
watch: { watch: {
isActive(newVal) { isActive(newVal) {
if (newVal) { if (newVal) {
this.$el.scrollIntoView({behavior: 'smooth'}); this.scrollIntoView()
} }
} }
} }