fix(video): stop playing video when modal closed (#640)

fixes #622
This commit is contained in:
Nolan Lawson 2018-11-12 16:20:59 -08:00 committed by GitHub
parent 94baf9e396
commit c54aaf2fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -131,8 +131,9 @@
let dialogElement = this.refs.node.parentElement
this._a11yDialog = new A11yDialog(dialogElement)
this._a11yDialog.on('hide', () => {
this._a11yDialog.destroy()
let { id } = this.get()
this.fire('close')
this._a11yDialog.destroy()
emit('destroyDialog', id)
requestAnimationFrame(() => document.body.removeChild(dialogElement))
})

View File

@ -4,6 +4,7 @@
background="var(--muted-modal-bg)"
muted="true"
className="video-modal-dialog"
on:close="onClose()"
>
<video {poster}
{src}
@ -11,6 +12,7 @@
{height}
aria-label="Video: {description || ''}"
controls
ref:video
/>
</ModalDialog>
<style>
@ -32,7 +34,12 @@
ModalDialog
},
methods: {
show
show,
onClose () {
if (this.refs.video && !this.refs.video.paused) {
this.refs.video.pause()
}
}
}
}
</script>