Closed lannka closed 6 years ago
Don't see a reason, TBH. Measurements are always done in px
in DOM APIs. 100% and 100vw probably indicate the desire to expand to the full viewport. This is good, but:
enterLightboxMode
or enterOverlayMode
)I agree expanding to full viewport should be handled via special API, not #attemptChangeSize
. But I think the request is different from entering a full screen mode. It is only resizing through attemptChangeSize
function. Even now, user can take the whole screen by calling attemptChangeSize
to a very large width/height, and I don't think we are applying any restrictions on the new width/height. User can always scroll away from the resized element.
Are we planning to apply any restriction on the percentage value? For example 100vw sounds reasonable, but to me 100vh does not.
Is %
and vw
vh
the only three we want to add support to ?
@lannka I'm not familiar with attemptResize
. Did you intend to indicate requestResize
or attemptChangeSize
instead? I feel this update would be helpful for both of them.
@zhouyx Is there documentation somewhere on attemptChangeSize
? Looks like parameters were added to support for margins. And just like requestResize
I assume the width and height parameters are numeric and are automatically assigned px as the unit? And yes in my opinion %
, vw
, and vh
are the only additional units needing support.
@dvoytenko I'm actually not looking to expand to the full viewport. For further information, this request came about because I'm trying to set the width and height of the
https://github.com/ampproject/amphtml/blob/master/src/service/resources-impl.js#L761 documented here. And yes the parameters are numeric and has px as the unit.
@zhouyx Thanks for the link. I'd like to try it out, but I'll need to pass the attemptChangeSize
). Is there a way to reference that from within a DFP ad? I can't get it because of js security issues. Perhaps it can be referenced as a part of window.parent.context?
@coreybyrnes: Ads only have access to window.context.requestResize(width, height)
. #attemptChangeSize
is only available to the AMP runtime (requestResize
uses it internally).
@jridgewell Good to know - thanks.
So can the original request to allow units be a part of the requestResize
continue?
Ok, discussed this in design-review today. The use case right now seems solvable by specifying width="100%" height="100%"
or width="100vw" height="100vh"
on whatever amp-element creates the iframe. So for ads:
<amp-ad type="..." width="100vw" height="100vh">
</amp-ad>
This, coupled with the current pixel resize API, seems to cover everything necessary.
I think being able to specify a unit other than the assumed px
is still a valid request so IMHO this should be reopened for further conversation.
As for the proposed solution, if the ad size needs to match the width and height attributes in the
@coreybyrnes we think it should be publisher's control to decide the width of the ad. If pub puts ad in a small fixed width, ad should not enlarge itself to full viewport width which may lead to an overflow.
Can you give example why this is necessary?
The issue I'm trying to solve for is #8097. There is no way to horizontally & vertically center the image asset served in a DFP ad into the flying-carpet component if the image is larger than the ad size and therefore the ad container (since the ad size determines the width & height of the container).
Reopening due to https://github.com/ampproject/amphtml/issues/8097#issuecomment-286897296. Ad servers only understand absolute pixels, which means you have to use width="320" height="100"
.
This issue hasn't been updated in awhile. @zhouyx Do you have any updates?
This issue hasn't been updated in awhile. @zhouyx Do you have any updates?
This issue hasn't been updated in awhile. @zhouyx Do you have any updates?
I think it's reasonable to expose the requestResizes
API with unit other than px feature to 3P iframes. internal attemptChangeSize()
API only accepting px
.
But is the feature still required since DPF ad has migrated to using Fast Fetch? to @lannka
Closing this because doubleclick supports specifying ad dimension explicitly in AMP now: https://github.com/ampproject/amphtml/issues/8097#issuecomment-406732234
As discussed here #7957, is it a good idea to support resizing to CSS values like:
@dvoytenko @zhouyx