Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix native ads cut off with max height #1419

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Conversation

dskamiotis
Copy link
Contributor

@dskamiotis dskamiotis commented Jun 17, 2024

What does this change?

This allows the viewport to be made <980px in width or to change orientation on an iPad without the native ad getting cut off at the the bottom.

Why?

Native ads resize on render and therefore change ratio (width and height), therefore when we reduce the width of the viewport or change the orientation on the iPad the bottom gets cut off.
The CSS states a max-height of 624px which persists at all breakpoints.

The resize is a Post Message, so when messenger tells us to resize (which only happens for in-house creatives) it should also check the container and remove max-height if necessary.

Screenshot

Before After
Screenshot 2024-06-17 at 16 42 03 Screenshot 2024-06-17 at 16 01 52

Copy link

changeset-bot bot commented Jun 17, 2024

🦋 Changeset detected

Latest commit: b64c6ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@guardian/commercial Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jun 17, 2024

Ad load time test results

For consented, top-above-nav took on average 4606ms to load.
For consentless, top-above-nav took on average 3039ms to load.

Test conditions:

  • 5mbps download speed
  • 1.5mbps upload speed
  • 150ms latency

@dskamiotis dskamiotis marked this pull request as ready for review June 17, 2024 15:03
@dskamiotis dskamiotis requested a review from a team as a code owner June 17, 2024 15:03
@@ -62,6 +62,8 @@ const resize = (
styles.height = normalise(specs.height);
}

adSlot.style.maxHeight = 'none';
Copy link
Member

@Jakeii Jakeii Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be inside the fastdom.mutate below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to be immediately applied in fastdom.mutate

@dskamiotis dskamiotis changed the title add conditional css to max height none fix native ads cut off with max height Jun 17, 2024
@@ -67,6 +67,7 @@ const resize = (

if (iframeContainer) {
Object.assign(iframeContainer.style, styles);
adSlot.style.maxHeight = 'none';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in the iframeContainer conditional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this would be appropriate, as we need an iFrameContainer to be present in order to apply the styling?
Do you mean to add the styling regardless of conditions?

return fastdom.mutate(() => {
    Object.assign(iframe.style, styles);

    if (iframeContainer) {
        Object.assign(iframeContainer.style, styles);
    }
    
    adSlot.style.maxHeight = 'none'; // Applied regardless of iframeContainer
});

@dskamiotis dskamiotis merged commit 08dc533 into main Jun 19, 2024
13 checks passed
@dskamiotis dskamiotis deleted the ds/fix-native-ads-cut-off branch June 19, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants