Conversation
jridgewell
left a comment
There was a problem hiding this comment.
I think this entire PR is unnecessary due to #7612. If there are issues with collapsing a fixed position ad (that won't cause a scroll adjustment), I'd rather update #attemptChangeSize (and by extension #attemptCollapse) to handle the case.
extensions/amp-ad/0.1/amp-ad-ui.js
Outdated
| * @private | ||
| */ | ||
| displayNoContentUI_() { | ||
| const adContainer = getAdContainer(this.baseInstance_.element); |
There was a problem hiding this comment.
I can also use the pre-calculate container value from
baseInstance
👍
extensions/amp-ad/0.1/amp-ad-ui.js
Outdated
| */ | ||
| displayNoContentUI_() { | ||
| const adContainer = getAdContainer(this.baseInstance_.element); | ||
| if (adContainer == 'AMP-STICKY-AD') { |
There was a problem hiding this comment.
We can extend this to amp-fx-flying-carpet, too.
|
I thought about always collapsing a fixed position ad (that won't cause a scroll adjustment) before. But in the case of scrollable lightbox, ad collapsing can still cause scroll adjustment. So restricting container to be either sticky-ad or flying-carpet is still required. |
|
@jridgewell I thought about it a little more and started to think |
This also affects iframe's, etc. I've also argued |
|
Agree that layer manager will eventually does everything here! Will close the issue and wait for layers then 😄 |
|
This is implementable in Resources, though, and much sooner than I'm going to be able Layers. // resources-impl.js
for (let i = 0; i < requestsChangeSize.length; i++) {
// other resize rules
let fixedPositionParent;
for (let el = element; el; el = el.parentElement) {
if (isFixed(el)) {
fixedPositionParent = el;
break;
}
if (el.nextSibling || el.previousSibling) {
break;
}
}
if (fixedPositionParent) {
// case 7 or 8 or something
// Resize allow because changing size of only element in fixed-position element
resize = true;
} |
|
I thought about it before. However I think it is not always the case that we can resize an element in fixed layer. For example: element resize in |
Isn't that taken care of by the |
|
Ah you're right! |
|
Maybe pass in an optional |
|
Two approaches. 1: have the element decide to force resize or not. 2: have resources manager decide to force resize. I used approach 1 in this PR because I figured it's a special case only for ads in Since I don't have a strong preference, will move the |
|
@jridgewell I just realized we can't force collapse |
|
I kinda feel this is not generic enough to fit in resource manager. It should only apply to |
|
Alright, let's go with the original review then. |
|
rewrite the |
07f778b to
98f2534
Compare
* force collapse sticky-ad * use getAdContainer * s * store pre calculate value * fix lint
* force collapse sticky-ad * use getAdContainer * s * store pre calculate value * fix lint
closes #6184
Only ad rendered in cross domain iframe has ad container value calculated before. Thus I decided to keep the code cleaner by always calculating container again.
I can also use the pre-calculate container value from
baseInstanceIf anyone thinks the call of#getAdContaineris expensive https://github.com/ampproject/amphtml/blob/master/src/ad-helper.js#L77@jridgewell I believe we will not force collapse an ad in flying-carpet?