Skip to content

Commit

Permalink
Fix FixedLayer experiment (#28514)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkimball authored May 26, 2020
1 parent 5048db3 commit a3a4906
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
9 changes: 8 additions & 1 deletion build-system/global-configs/experiments-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"expiration_date_utc": "2020-06-30",
"define_experiment_constant": "INTERSECTION_OBSERVER_POLYFILL_INABOX"
},
"experimentB": {},
"experimentB": {
"name": "MoveFixedLayer",
"environment": "AMP",
"command": "gulp dist --define_experiment_constant=MOVE_FIXED_LAYER",
"issue": "https://github.com/ampproject/amphtml/issues/27120",
"expiration_date_utc": "2021-01-01",
"define_experiment_constant": "MOVE_FIXED_LAYER"
},
"experimentC": {}
}
4 changes: 3 additions & 1 deletion src/inabox/inabox-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ class InaboxViewportImpl {
}

/** @override */
updateFixedLayer() {}
updateFixedLayer() {
return Promise.resolve();
}

/** @override */
addToFixedLayer(unusedElement, opt_forceTransfer) {
Expand Down
24 changes: 17 additions & 7 deletions src/service/viewport/viewport-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,9 @@ export class ViewportImpl {
);

this.enterOverlayMode();
this.fixedLayer_.enterLightbox(opt_requestingElement, opt_onComplete);
if (this.fixedLayer_) {
this.fixedLayer_.enterLightbox(opt_requestingElement, opt_onComplete);
}

if (opt_requestingElement) {
this.maybeEnterFieLightboxMode(
Expand All @@ -618,7 +620,9 @@ export class ViewportImpl {
/* cancelUnsent */ true
);

this.fixedLayer_.leaveLightbox();
if (this.fixedLayer_) {
this.fixedLayer_.leaveLightbox();
}
this.leaveOverlayMode();

if (opt_requestingElement) {
Expand Down Expand Up @@ -779,16 +783,25 @@ export class ViewportImpl {

/** @override */
updateFixedLayer() {
this.fixedLayer_.update();
if (!this.fixedLayer_) {
return Promise.resolve();
}
return this.fixedLayer_.update();
}

/** @override */
addToFixedLayer(element, opt_forceTransfer) {
if (!this.fixedLayer_) {
return Promise.resolve();
}
return this.fixedLayer_.addElement(element, opt_forceTransfer);
}

/** @override */
removeFromFixedLayer(element) {
if (!this.fixedLayer_) {
return;
}
this.fixedLayer_.removeElement(element);
}

Expand Down Expand Up @@ -1034,10 +1047,7 @@ export class ViewportImpl {
const oldSize = this.size_;
this.size_ = null; // Need to recalc.
const newSize = this.getSize();
const promise = this.fixedLayer_
? this.fixedLayer_.update()
: Promise.resolve();
promise.then(() => {
this.updateFixedLayer().then(() => {
const widthChanged = !oldSize || oldSize.width != newSize.width;
this.changed_(/*relayoutAll*/ widthChanged, 0);
const sizeChanged = widthChanged || oldSize.height != newSize.height;
Expand Down
1 change: 1 addition & 0 deletions src/service/viewport/viewport-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export class ViewportInterface extends Disposable {

/**
* Updates the fixed layer.
* @return {!Promise}
*/
updateFixedLayer() {}

Expand Down

0 comments on commit a3a4906

Please sign in to comment.