1
0
mirror of https://github.com/videojs/video.js.git synced 2025-03-29 22:07:10 +02:00

fix: exit full window mode with Esc key (#7224)

This commit is contained in:
FredTsang 2021-05-12 00:54:15 +08:00 committed by GitHub
parent 0e46624f1a
commit e9953e59fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View File

@ -2979,9 +2979,11 @@ class Player extends Component {
fullWindowOnEscKey(event) {
if (keycode.isEventKey(event, 'Esc')) {
if (this.isFullscreen() === true) {
this.exitFullscreen();
} else {
this.exitFullWindow();
if (!this.isFullWindow) {
this.exitFullscreen();
} else {
this.exitFullWindow();
}
}
}
}

View File

@ -207,3 +207,20 @@ QUnit.test('fullscreenOptions from function args should override player options'
player.dispose();
});
QUnit.test('fullwindow mode should exit when ESC event triggered', function(assert) {
const player = FullscreenTestHelpers.makePlayer(true);
player.enterFullWindow();
assert.ok(player.isFullWindow, 'enterFullWindow should be called');
const evt = TestHelpers.createEvent('keydown');
evt.keyCode = 27;
evt.which = 27;
player.boundFullWindowOnEscKey_(evt);
// player.fullWindowOnEscKey(evt);
assert.equal(player.isFullWindow, false, 'exitFullWindow should be called');
player.dispose();
});