requestResize broke layout="responsive"
Short description of your issue:
As we discuss on #3182 , we can't be sure to be closed by AMP Framework when no content available
So we choose to start with an amp-ad container closed (height=1) and only open it if we have some ad to display, according to the AMP resizing rules
BUT use of context.requestResize broke the layout="responsive" behaviors
We just want to update the responsive ratio on our amp-ad container get by width and height (update 300 x 1 to 300 x 220) but a successful requestResize force width and height on element style attribute, in consequence this element is not responsive anymore. It's a problem for us when an orientation change append on mobile
Can we have a way to just update the responsive ratio, and not directly the css size ?
How do we reproduce the issue?
- Start an amp-ad with layout="responsive"
- Call context.requestResize from it with any size
- Component amp-ad is not responsive anymore
What browsers are affected?
Mobile browser (affected by orientation change)
Which AMP version is affected?
I think it was always the case, but not especially an issue. Maybe a new feature ?
I don't think this is something we want to support directly. I'd expect you to send another requestResize after an orientation change. Any reason that doesn't work?
Hi @cramforce ,
Okay i've just tested and it seems work well 80% of time (sometimes denied i don't know why yet)
Sorry for the misunderstanding, the AMP resizing rules are not very clear about that. We 've got some troubles concerning opening or closing the amp-ad component if user scroll fast to our slot and is in view during the resize request.
Could you please tell me a little bit more about these rules ?
we hoped to enjoy your effective responsive layout...
@RonanDrouglazet The best place to read about ad resizing is here: https://github.com/ampproject/amphtml/blob/74b9daf2263d45c401dbf4810c9751c15d86e46a/ads/README.md#ad-resizing
The ad element will follow the specified layout, e.g. layout=responsive, which will automatically resize based on the page layout. As an Ad author you can listen to your window's resize events and react to them as necessary and you can override the specified layout using requestResize. Once you override it - you are responsible for layout going forward. However, the resize request can fail (see onResizeDenied) callback. Whether or not it fails depends on many things and that doesn't have to do with responsiveness but whether or not forcing layout changes would be disruptive for the user.
More specifically:
So we choose to start with an amp-ad container closed (height=1) and only open it if we have some ad to display, according to the AMP resizing rules
This is exactly what the layout system tries to avoid. The resizing like this is very painful for the user. We allow it when we can confirm that the user's reading experience will not be disrupted.
BUT use of context.requestResize broke the layout="responsive" behaviors
This is intentional as well. Once you change the element changes the size, it's responsible for size going forward.
I will close this issue, but please feel free to respond with more questions as needed.