Skip to content

Commit

Permalink
[amp-list] resize amp-list on viewport resize experiment (ampproject#…
Browse files Browse the repository at this point in the history
…19946)

* Draft changes for toggling amp-list height on orientation change

* Update experiment name
  • Loading branch information
cathyxz authored and Noran Azmy committed Mar 22, 2019
1 parent e2ece46 commit 5f7b2e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions extensions/amp-list/0.1/amp-list.js
Expand Up @@ -229,6 +229,13 @@ export class AmpList extends AMP.BaseElement {
if (placeholder) {
this.attemptToFit_(placeholder);
}

if (isExperimentOn(this.win, 'amp-list-viewport-resize')) {
this.getViewport().onResize(() => {
this.attemptToFit_(dev().assertElement(this.container_));
});
}

return this.fetchList_();
}

Expand Down Expand Up @@ -668,6 +675,9 @@ export class AmpList extends AMP.BaseElement {
* @private
*/
attemptToFit_(target) {
if (this.element.getAttribute('layout') == Layout.CONTAINER) {
return;
}
this.measureElement(() => {
const scrollHeight = target./*OK*/scrollHeight;
const height = this.element./*OK*/offsetHeight;
Expand Down
6 changes: 6 additions & 0 deletions tools/experiments/experiments.js
Expand Up @@ -408,6 +408,12 @@ const EXPERIMENTS = [
spec: 'https://github.com/ampproject/amphtml/issues/10837',
cleanupIssue: 'https://github.com/ampproject/amphtml/issues/XXXXX',
},
{
id: 'amp-list-viewport-resize',
name: 'Enables amp-list to resize on viewport resize',
spec: 'https://github.com/ampproject/amphtml/issues/19945',
cleanupIssue: 'https://github.com/ampproject/amphtml/issues/19945',
},
];

if (getMode().localDev) {
Expand Down

0 comments on commit 5f7b2e8

Please sign in to comment.