Skip to content

Commit

Permalink
🐛 [story-ads] Fix ad badge placement in landscape mode (#35750)
Browse files Browse the repository at this point in the history
* fix badge placement

* space
  • Loading branch information
calebcordry committed Oct 8, 2021
1 parent 8a7e55d commit 1fb1ab4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
15 changes: 11 additions & 4 deletions extensions/amp-story-auto-ads/0.1/amp-story-auto-ads-ad-badge.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


.i-amphtml-ad-overlay-container {
align-items: center !important;
display: flex !important;
Expand All @@ -18,8 +16,15 @@
right: 0 !important;
}

.i-amphtml-ad-overlay-container[desktop-fullbleed] {
/* On desktop a story page has a with of 45vh. */
left: calc(50vw - 22.5vh) !important;
/* And a height of 75 vh. */
top: 12.5vh !important;
}

.i-amphtml-story-ad-badge-svg {
top: 50% !important;
top: 50% !important;
left: 50% !important;
position: relative !important;
transform: translate(-50%, -50%) !important;
Expand All @@ -45,5 +50,7 @@
.i-amphtml-ad-overlay-container[desktop-one-panel] {
top: var(--i-amphtml-story-desktop-one-panel-responsive-margin) !important;
/* Calculates position by factoring in page width. */
left: calc(50vw - var(--i-amphtml-story-desktop-one-panel-width) / 2) !important;
left: calc(
50vw - var(--i-amphtml-story-desktop-one-panel-width) / 2
) !important;
}
7 changes: 6 additions & 1 deletion extensions/amp-story-auto-ads/0.1/amp-story-auto-ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const MUSTACHE_TAG = 'amp-mustache';
/** @enum {string} */
export const Attributes = {
AD_SHOWING: 'ad-showing',
DESKTOP_FULLBLEED: 'desktop-fullbleed',
DESKTOP_ONE_PANEL: 'desktop-one-panel',
DIR: 'dir',
PAUSED: 'paused',
Expand Down Expand Up @@ -313,11 +314,15 @@ export class AmpStoryAutoAds extends AMP.BaseElement {
*/
onUIStateUpdate_(uiState) {
this.mutateElement(() => {
const {DESKTOP_ONE_PANEL} = Attributes;
const {DESKTOP_FULLBLEED, DESKTOP_ONE_PANEL} = Attributes;
this.adBadgeContainer_.removeAttribute(DESKTOP_FULLBLEED);
this.adBadgeContainer_.removeAttribute(DESKTOP_ONE_PANEL);
// TODO(#33969) can no longer be null when launched.
this.progressBarBackground_?.removeAttribute(DESKTOP_ONE_PANEL);

if (uiState === UIType.DESKTOP_FULLBLEED) {
this.adBadgeContainer_.setAttribute(DESKTOP_FULLBLEED, '');
}
if (uiState === UIType.DESKTOP_ONE_PANEL) {
this.adBadgeContainer_.setAttribute(DESKTOP_ONE_PANEL, '');
this.progressBarBackground_?.setAttribute(DESKTOP_ONE_PANEL, '');
Expand Down

0 comments on commit 1fb1ab4

Please sign in to comment.