amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Feature Request: amp-carousel set default displayed / center image/text

Open QES opened this issue 9 years ago • 13 comments

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.

QES avatar Oct 18 '17 14:10 QES

@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.

aghassemi avatar Oct 18 '17 16:10 aghassemi

/cc @ericlindley-g

aghassemi avatar Oct 18 '17 16:10 aghassemi

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 ?

ericlindley-g avatar Oct 18 '17 17:10 ericlindley-g

i don't think this applies to type=carousel with the current setup. In slides its definitely doable

camelburrito avatar Oct 18 '17 19:10 camelburrito

@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.

QES avatar Oct 19 '17 08:10 QES

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.

aghassemi avatar Oct 19 '17 15:10 aghassemi

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.

brentthomascodes avatar Sep 10 '18 21:09 brentthomascodes

@bthomas16 we have a current project trying to improve amp-carousel will consider this feature request as part of the project. /cc @nainar

aghassemi avatar Sep 10 '18 22:09 aghassemi

Added this to the feature requests for amp-carousel rewrite.

nainar avatar Sep 10 '18 22:09 nainar

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.

TWsky avatar Sep 13 '18 05:09 TWsky

how do i identify active slide using type= carousel, i've to apply certain UI styles to the active slide

gaurav-coverfox avatar May 15 '19 14:05 gaurav-coverfox

Closed via #23840

sparhami avatar Aug 09 '19 17:08 sparhami

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

nainar avatar Aug 14 '19 22:08 nainar