Skip to content

Commit

Permalink
delay updateBorderPadding (ampproject#6529)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouyx authored and Vanessa Pasque committed Dec 22, 2016
1 parent daa12ad commit 020c065
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions extensions/amp-sticky-ad/1.0/amp-sticky-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ class AmpStickyAd extends AMP.BaseElement {
this.deferMutate(() => {
this.visible_ = true;
this.viewport_.addToFixedLayer(this.element);
// Add border-bottom to the body to compensate space that was taken
// by sticky ad, so no content would be blocked by sticky ad unit.
const borderBottom = this.element./*OK*/offsetHeight;
this.viewport_.updatePaddingBottom(borderBottom);
this.addCloseButton_();
this.scheduleLayoutForAd_();
});
Expand Down Expand Up @@ -173,6 +169,10 @@ class AmpStickyAd extends AMP.BaseElement {
this.vsync_.mutate(() => {
// Set sticky-ad to visible and change container style
this.element.setAttribute('visible', '');
// Add border-bottom to the body to compensate space that was taken
// by sticky ad, so no content would be blocked by sticky ad unit.
const borderBottom = this.element./*OK*/offsetHeight;
this.viewport_.updatePaddingBottom(borderBottom);
this.forceOpacity_();
});
});
Expand Down
4 changes: 4 additions & 0 deletions extensions/amp-sticky-ad/1.0/test/test-amp-sticky-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ describes.realWin('amp-sticky-ad 1.0 with real ad child', {
};

impl.displayAfterScroll_();
impl.layoutAd_();
impl.ad_.dispatchEvent(new Event('amp:load:end'));
return impl.viewport_.ampdoc.whenBodyAvailable().then(() => {
let borderWidth = win.getComputedStyle(win.document.body, null)
.getPropertyValue('border-bottom-width');
Expand Down Expand Up @@ -368,6 +370,8 @@ describes.realWin('amp-sticky-ad 1.0 with real ad child', {
};

impl.displayAfterScroll_();
impl.layoutAd_();
impl.ad_.dispatchEvent(new Event('amp:load:end'));
return impl.viewport_.ampdoc.whenBodyAvailable().then(() => {
let borderWidth = win.getComputedStyle(win.document.body, null)
.getPropertyValue('border-bottom-width');
Expand Down

0 comments on commit 020c065

Please sign in to comment.