Skip to content

Sticky ad: wait for fixed layer to complete before loading an ad#9171

Merged
dvoytenko merged 2 commits intoampproject:masterfrom
dvoytenko:fixes169
May 5, 2017
Merged

Sticky ad: wait for fixed layer to complete before loading an ad#9171
dvoytenko merged 2 commits intoampproject:masterfrom
dvoytenko:fixes169

Conversation

@dvoytenko
Copy link
Copy Markdown
Contributor

Partial for #8780.

What likely was happening here is that the ad's iframe was reloaded by browser when the ad was transferred to the fixed layer. Browsers always reset/reload iframe's window when reparented, so this is somewhat likely.

/cc @keithwrightbos

@dvoytenko dvoytenko requested a review from zhouyx May 5, 2017 18:43
Copy link
Copy Markdown
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

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

LGTM

onScroll_() {
if (isExperimentOn(this.win, EARLY_LOAD_EXPERIMENT)) {
const scrollTop = this.viewport_.getScrollTop();
if (isExperimentOn(this.win, EARLY_LOAD_EXPERIMENT) && scrollTop > 1) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think there's need to check scrollTop here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The problem is that iOS often offsets to 1 to avoid scroll freeze issue. See https://github.com/ampproject/amphtml/blob/master/src/service/viewport-impl.js#L1478

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Er..... 😢

this.viewport_.addToFixedLayer(this.element);
this.addCloseButton_();
this.scheduleLayoutForAd_();
this.viewport_.addToFixedLayer(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the promise always promised to resolve?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes

@dvoytenko dvoytenko merged commit 64fbbe7 into ampproject:master May 5, 2017
@dvoytenko dvoytenko deleted the fixes169 branch May 5, 2017 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants