Feature Request: amp-carousel set default displayed / center image/text
When you have an "amp-carousel" there is no way to start that carousel at a point other than element 1 in the list.
Why might this be useful?
I have a list of images and they relate to dates current/past and future - it would be useful to start with "today" shown and centre and allow people to scroll back (into the past) of forward into the future.
I see this most useful in the carousel format where you have a selection of images and on different displays you might see one, three, five images as the display device gets wider but the default is the center and you can move back / forward through the images rather than starting at 1 and moving forward only.
@camelburrito looks like amp-carousel supports [slide] attribute for binding but does not support slide as an attribute for initial value, do you know if there is a reason for this? If not, we should be able to just expose this attribute for initial slide as well.
/cc @ericlindley-g
Would be excited to support this—both for type=slides and type=carousel (the latter might then support Medium-style side-scrolling nav at the top of the page)
Concerns: Would this cause issues for pre-rendering? Would it be an issue in delaying initial load in general? @camelburrito @Gregable ?
i don't think this applies to type=carousel with the current setup. In slides its definitely doable
@ericlindley-g I agree that in type=carousel this could be used as a simple menu / option selector.
This is a very similar issue to my use case and is interesting for type=carousel because what is might show will vary depending on the width of the device.
I noticed that there was provision for selecting a particular image but no way to initiate it on load or (apparently) any way to trigger the event without a button/tap.
we can support this for amp-carousel to by scrolling to the item specified by its index and making it be in the middle of the carousel. slide as a name is not great for this case, show=<index> might be better meaning we should also depreciate the bind-specific [slide] in favour of [show] as well.
Where are we with this feature support? I have been blocked by the following use case:
While using amp-carousel inside amp-lightbox, I am unable to set the carousel's initial slide index upon opening the amp-lightbox. This is because amp-lightbox has a default of layout="nodisplay", which makes the amp-carousel unable to be targeted until the lightbox has been displayed by user interaction (this means the slide index will always start at 0 the first time the lightbox/carousel are opened).
I am working on an e-commerce page and the 'see more' for each product review is being used to open the amp-lightbox and then change that carousel's slide-index to the selected review's index. I have tried both binding to [slide] with an amp-state variable as well as goToSlide(index={{reviewIndex}}). But still, the carousel always defaults to the 0 index slide on only the first attempt to open it.
@bthomas16 we have a current project trying to improve amp-carousel will consider this feature request as part of the project. /cc @nainar
Added this to the feature requests for amp-carousel rewrite.
Another use case from here is willing to set the initial slide index by reading the query string (or even the anchor (#)) on the url, setting the first into view slide as expected with the corresponding url anchor. Hoping this can be also be considered into the feature request.
how do i identify active slide using type= carousel, i've to apply certain UI styles to the active slide
Closed via #23840
This issue is fixed for all users who upgrade their <amp-carousel> version to 0.2 which should be available on August 28.
For more details please see documentation here: https://github.com/ampproject/amphtml/blob/master/extensions/amp-carousel/amp-carousel.md