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

fixes #622
pull/644/head
Nolan Lawson 2018-11-12 16:20:59 -08:00 zatwierdzone przez GitHub
rodzic 94baf9e396
commit c54aaf2fa4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 10 dodań i 2 usunięć

Wyświetl plik

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

Wyświetl plik

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