I'm using amp-list and I would like to have a dynamic height based on the results that I got. There is a way to do it? I couldn't get it done.
<amp-list src="request-url">
<template type="amp-mustache" id="amp-template-id">
...
</template>
</amp-list>
All the available layouts requires dimensions at the amp-list level or parent level. However I don't want to specify an height. My results can either have 1 or 12 items.
There is no dynamic layout in AMP (this is to avoid reflow while the page is loading, which is one of the big advantages of AMP). However, the amp-list will automatically take more space if required (and available).
You can do the following three things to support this:
Here is what the official docs say about this:
If amp-list needs more space after loading it requests the AMP runtime to update its height using the normal AMP flow. If AMP Runtime cannot satisfy the request for new height, it will display overflow element when available. Notice however, the typical placement of amp-list elements at the bottom of the document almost always guarantees that AMP Runtime can resize it.
source: https://www.ampproject.org/docs/reference/components/amp-list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With