Pause video on component update if not expanded.

This commit is contained in:
Evelyn Eastmond committed 2019-05-28 20:34:14 -04:00
1 parent 3e0d5b9ede
commit 98a007a17e
1 file changed
+9
+9
View File
@@ -111,6 +111,14 @@ class VideoStep extends React.Component {
script2.async = true;
document.body.appendChild(script2);
}
componentDidUpdate () {
// if not expanded, pause video?
if (!this.props.expanded) {
// eslint-disable-next-line no-undef
const video = Wistia.api(`${this.props.video}`);
video.pause();
}
}
render () {
return (
// Video step needs to know if the card is being dragged to cover the video
@@ -132,6 +140,7 @@ class VideoStep extends React.Component {
VideoStep.propTypes = {
dragging: PropTypes.bool.isRequired,
expanded: PropTypes.bool.isRequired,
video: PropTypes.string.isRequired
};