Skip to content

Commit

Permalink
Fix: only hide the filmstrip if it exists (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Press authored Aug 15, 2017
1 parent 2fd0655 commit 1c70dd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/viewers/media/MediaControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ class MediaControls extends EventEmitter {
* @return {void}
*/
filmstripHideHandler() {
if (!this.isScrubbing) {
if (!this.isScrubbing && this.filmstripEl) {
this.filmstripContainerEl.style.display = 'none';
}
}
Expand Down
18 changes: 17 additions & 1 deletion src/lib/viewers/media/__tests__/MediaControls-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,21 @@ describe('lib/viewers/media/MediaControls', () => {
expect(stubs.show).to.be.called;
});

it('should remove the show controls class and hide the filmstrip if the wrapper element and parent exist', () => {
it('should remove the show controls class if the wrapper element and parent exist', () => {
mediaControls.preventHiding = false;
stubs.isSettingsVisible.returns(false);

mediaControls.hide();
expect(stubs.show).to.not.be.called;
expect(mediaControls.wrapperEl.parentNode.classList.contains('bp-media-controls-is-visible')).to.be.false;
});

it('should hide the filmstrip', () => {
mediaControls.preventHiding = false;
stubs.isSettingsVisible.returns(false);
mediaControls.filmstripEl = document.createElement('div');

mediaControls.hide();
expect(stubs.filmstripHideHandler).to.be.called;
});
});
Expand Down Expand Up @@ -995,6 +1003,14 @@ describe('lib/viewers/media/MediaControls', () => {
mediaControls.filmstripHideHandler();
expect(mediaControls.filmstripContainerEl.style.display).to.equal('');
});

it('should do nothing if there is no filmstrip', () => {
mediaControls.isScrubbing = false;
mediaControls.filmstripEl = null;

mediaControls.filmstripHideHandler();
expect(mediaControls.filmstripContainerEl.style.display).to.equal('');
});
});

describe('initSubtitles()', () => {
Expand Down

0 comments on commit 1c70dd4

Please sign in to comment.