Resizing the ad container while having it on display none will return offset width and height of 0, which will cause ads not to play when ad sizes are set within the clients DSP. Also making sure that the inner containers of the ad container are full size. The container is now hidden/ displayed using z-index.

This commit is contained in:
Arthur Hulsman 2018-03-07 15:43:48 +01:00
parent 409b588458
commit 819f7d1080
2 changed files with 17 additions and 6 deletions

View File

@ -111,7 +111,6 @@ class Ads {
// Create the container for our advertisements // Create the container for our advertisements
this.elements.container = utils.createElement('div', { this.elements.container = utils.createElement('div', {
class: this.player.config.classNames.ads, class: this.player.config.classNames.ads,
hidden: '',
}); });
this.player.elements.container.appendChild(this.elements.container); this.player.elements.container.appendChild(this.elements.container);
@ -451,8 +450,8 @@ class Ads {
* Resume our video. * Resume our video.
*/ */
resumeContent() { resumeContent() {
// Hide our ad container // Hide the advertisement container
utils.toggleHidden(this.elements.container, true); this.elements.container.style.zIndex = '';
// Ad is stopped // Ad is stopped
this.playing = false; this.playing = false;
@ -467,8 +466,8 @@ class Ads {
* Pause our video * Pause our video
*/ */
pauseContent() { pauseContent() {
// Show our ad container. // Show the advertisement container
utils.toggleHidden(this.elements.container, false); this.elements.container.style.zIndex = '3';
// Ad is playing. // Ad is playing.
this.playing = true; this.playing = true;

View File

@ -9,7 +9,19 @@
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
z-index: 3; // Above the controls z-index: -1; // Hide it.
// Make sure the inner container is big enough for the ad creative.
> div {
position: absolute;
width: 100%;
height: 100%;
iframe {
position: absolute;
width: 100%;
height: 100%;
}
}
&::after { &::after {
background: rgba($plyr-color-gunmetal, 0.8); background: rgba($plyr-color-gunmetal, 0.8);