Skip to content

Commit

Permalink
fix(player): Fixed error when running tests on Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa8626 committed Feb 4, 2019
1 parent 6f6dfc9 commit aaee1ea
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
22 changes: 13 additions & 9 deletions dist/openplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5888,15 +5888,17 @@ var Settings = function () {
this.hideEvent = function () {
var timeout;

if (timeout) {
if (timeout && typeof window !== 'undefined') {
window.cancelAnimationFrame(timeout);
}

timeout = window.requestAnimationFrame(function () {
_this.menu.innerHTML = _this.originalOutput;
if (typeof window !== 'undefined') {
timeout = window.requestAnimationFrame(function () {
_this.menu.innerHTML = _this.originalOutput;

_this.menu.setAttribute('aria-hidden', 'true');
});
_this.menu.setAttribute('aria-hidden', 'true');
});
}
};

this.removeEvent = function (e) {
Expand Down Expand Up @@ -7388,13 +7390,15 @@ var Ads = function () {
var mode = target.getAttribute('data-fullscreen') === 'true' ? google.ima.ViewMode.FULLSCREEN : google.ima.ViewMode.NORMAL;
var timeout;

if (timeout) {
if (timeout && typeof window !== 'undefined') {
window.cancelAnimationFrame(timeout);
}

timeout = window.requestAnimationFrame(function () {
_this2.adsManager.resize(width && height ? width : target.offsetWidth, width && height ? height : target.offsetHeight, mode);
});
if (typeof window !== 'undefined') {
timeout = window.requestAnimationFrame(function () {
_this2.adsManager.resize(width && height ? width : target.offsetWidth, width && height ? height : target.offsetHeight, mode);
});
}
}
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion dist/openplayer.min.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/js/controls/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,16 @@ class Settings implements PlayerComponent {

this.hideEvent = () => {
let timeout;
if (timeout) {
if (timeout && typeof window !== 'undefined') {
window.cancelAnimationFrame(timeout);
}

timeout = window.requestAnimationFrame(() => {
this.menu.innerHTML = this.originalOutput;
this.menu.setAttribute('aria-hidden', 'true');
});
if (typeof window !== 'undefined') {
timeout = window.requestAnimationFrame(() => {
this.menu.innerHTML = this.originalOutput;
this.menu.setAttribute('aria-hidden', 'true');
});
}
};

this.removeEvent = (e: CustomEvent) => {
Expand Down
18 changes: 10 additions & 8 deletions src/js/media/ads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,18 @@ class Ads {

let timeout;

if (timeout) {
if (timeout && typeof window !== 'undefined') {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(() => {
this.adsManager.resize(
width && height ? width : target.offsetWidth,
width && height ? height : target.offsetHeight,
mode,
);
});
if (typeof window !== 'undefined') {
timeout = window.requestAnimationFrame(() => {
this.adsManager.resize(
width && height ? width : target.offsetWidth,
width && height ? height : target.offsetHeight,
mode,
);
});
}
}
}

Expand Down

0 comments on commit aaee1ea

Please sign in to comment.