Skip to content

Commit

Permalink
Fixed merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa8626 committed Jun 16, 2017
2 parents 01e8906 + a46180d commit e1b6f57
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 26 deletions.
33 changes: 23 additions & 10 deletions build/mediaelement-and-player.js
Expand Up @@ -1223,12 +1223,14 @@ Object.assign(_player2.default.prototype, {

player.fullscreenBtn = fullscreenBtn;

t.globalBind('keydown', function (e) {
t.exitFullscreenCallback = function (e) {
var key = e.which || e.keyCode || 0;
if (key === 27 && (Features.HAS_TRUE_NATIVE_FULLSCREEN && Features.IS_FULLSCREEN || t.isFullScreen)) {
player.exitFullScreen();
}
});
};

t.globalBind('keydown', t.exitFullscreenCallback);

t.normalHeight = 0;
t.normalWidth = 0;
Expand Down Expand Up @@ -4113,13 +4115,15 @@ var MediaElementPlayer = function () {
t.setControlsSize();
}, 0);

t.globalBind('resize', function () {
t.globalResizeCallback = function () {
if (!(t.isFullScreen || _constants.HAS_TRUE_NATIVE_FULLSCREEN && _document2.default.webkitIsFullScreen)) {
t.setPlayerSize(t.width, t.height);
}

t.setControlsSize();
});
};

t.globalBind('resize', t.globalResizeCallback);
}

if (autoplay && isNative) {
Expand Down Expand Up @@ -4627,7 +4631,7 @@ var MediaElementPlayer = function () {
}
}
if (events.w) {
var _eventList2 = events.d.split(' ');
var _eventList2 = events.w.split(' ');
for (var _i3 = 0, _total3 = _eventList2.length; _i3 < _total3; _i3++) {
_eventList2[_i3].split('.').reduce(function (part, e) {
_window2.default.removeEventListener(e, callback, false);
Expand Down Expand Up @@ -4848,16 +4852,20 @@ var MediaElementPlayer = function () {
t.keyboardAction = true;
});

t.globalBind('keydown', function (event) {
t.globalKeydownCallback = function (event) {
var container = _document2.default.activeElement.closest('.' + t.options.classPrefix + 'container'),
target = t.media.closest('.' + t.options.classPrefix + 'container');
t.hasFocus = !!(container && target && container.id === target.id);
return t.onkeydown(player, media, event);
});
};

t.globalBind('click', function (event) {
t.globalClickCallback = function (event) {
t.hasFocus = !!event.target.closest('.' + t.options.classPrefix + 'container');
});
};

t.globalBind('keydown', t.globalKeydownCallback);

t.globalBind('click', t.globalClickCallback);
}
}, {
key: 'onkeydown',
Expand Down Expand Up @@ -5057,7 +5065,12 @@ var MediaElementPlayer = function () {
offscreen.remove();
t.container.remove();
}
t.globalUnbind();
t.globalUnbind('resize', t.globalResizeCallback);
t.globalUnbind('keydown', t.globalKeydownCallback);
if (typeof t.exitFullscreenCallback === 'function') {
t.globalUnbind('keydown', t.exitFullscreenCallback);
}
t.globalUnbind('click', t.globalClickCallback);

delete t.media.player;
}
Expand Down
2 changes: 1 addition & 1 deletion build/mediaelement-and-player.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -17,6 +17,7 @@
* Removed `mediaelementplayer` bundles, considered unnecessary @rafa8626
* Added new middleware layer to allow interaction with other players @rafa8626
* Use flex-box to reduce calculation via Javascript on control bar (https://github.com/mediaelement/mediaelement/pull/2261) @marcobiedermann and @rafa8626
* Fixed issue with events not being unbound when player is destroyed @rafa8626

*4.1.3 (2017/06/06)*

Expand Down
6 changes: 4 additions & 2 deletions src/js/features/fullscreen.js
Expand Up @@ -101,12 +101,14 @@ Object.assign(MediaElementPlayer.prototype, {

player.fullscreenBtn = fullscreenBtn;

t.globalBind('keydown', (e) => {
t.exitFullscreenCallback = (e) => {
const key = e.which || e.keyCode || 0;
if (key === 27 && ((Features.HAS_TRUE_NATIVE_FULLSCREEN && Features.IS_FULLSCREEN) || t.isFullScreen)) {
player.exitFullScreen();
}
});
};

t.globalBind('keydown', t.exitFullscreenCallback);

t.normalHeight = 0;
t.normalWidth = 0;
Expand Down
35 changes: 22 additions & 13 deletions src/js/player.js
Expand Up @@ -1020,18 +1020,19 @@ class MediaElementPlayer {
t.setControlsSize();
}, 0);


// adjust controls whenever window sizes (used to be in fullscreen only)
t.globalBind('resize', () => {

t.globalResizeCallback = () => {
// don't resize for fullscreen mode
if (!(t.isFullScreen || (HAS_TRUE_NATIVE_FULLSCREEN && document.webkitIsFullScreen))) {
t.setPlayerSize(t.width, t.height);
}

// always adjust controls
t.setControlsSize();
});
};


// adjust controls whenever window sizes (used to be in fullscreen only)
t.globalBind('resize', t.globalResizeCallback);
}

// force autoplay for HTML5
Expand Down Expand Up @@ -1584,7 +1585,7 @@ class MediaElementPlayer {
}
}
if (events.w) {
const eventList = events.d.split(' ');
const eventList = events.w.split(' ');
for (let i = 0, total = eventList.length; i < total; i++) {
eventList[i].split('.').reduce(function (part, e) {
window.removeEventListener(e, callback, false);
Expand Down Expand Up @@ -1824,21 +1825,24 @@ class MediaElementPlayer {
t.keyboardAction = true;
});

// listen for key presses
t.globalBind('keydown', (event) => {
t.globalKeydownCallback = (event) => {
const
container = document.activeElement.closest(`.${t.options.classPrefix}container`),
target = t.media.closest(`.${t.options.classPrefix}container`)
;
t.hasFocus = !!(container && target && container.id === target.id);
return t.onkeydown(player, media, event);
});
};

t.globalClickCallback = (event) => {
t.hasFocus = !!(event.target.closest(`.${t.options.classPrefix}container`));
};

// listen for key presses
t.globalBind('keydown', t.globalKeydownCallback);

// check if someone clicked outside a player region, then kill its focus
t.globalBind('click', (event) => {
t.hasFocus = !!(event.target.closest(`.${t.options.classPrefix}container`));
});
t.globalBind('click', t.globalClickCallback);

}

Expand Down Expand Up @@ -2085,7 +2089,12 @@ class MediaElementPlayer {
offscreen.remove();
t.container.remove();
}
t.globalUnbind();
t.globalUnbind('resize', t.globalResizeCallback);
t.globalUnbind('keydown', t.globalKeydownCallback);
if (typeof t.exitFullscreenCallback === 'function') {
t.globalUnbind('keydown', t.exitFullscreenCallback);
}
t.globalUnbind('click', t.globalClickCallback);

delete t.media.player;
}
Expand Down

0 comments on commit e1b6f57

Please sign in to comment.