Closed isaiahscheel closed 2 years ago
@geoffrich you had a huge hand in creating this element, I seem to remember this issue happening during dev. Do you have any insight into that and any guidance on how we can do this update?
This sounds vaguely familiar - I have some ideas, will hack on it a bit and let you know what I think.
@blackfalcon @isaiahscheel what about something like this? https://github.com/AlaskaAirlines/auro-carousel/commit/6fadca8e2a2bcaedf96b96c3669ab21379eed0eb
We can add a centerElement
method to the carousel that will center the given element inside the carousel. This makes it generic -- you can pass the selected pane yourself, or any element inside the carousel that you want to center. I didn't want to add any logic to the carousel that was coupled to auro-pane
.
It can be used like so:
const carousel = document.querySelector('auro-carousel') // or bind:this in Svelte
const selected = document.querySelector('auro-pane[selected]');
carousel.centerElement(selected);
I added an example to the demo page that centers the selected element every time it's clicked:
Will this API work for you?
@geoffrich This would be a very helpful! Having the carousel do the calculation and scrolling would be a very welcome feature.
@geoffrich this is all you buddy... please mark in progress
when you have started work.
:tada: This issue has been resolved in version 1.3.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Is your feature request related to a problem? Please describe.
Flight search uses auro-carousel to hold the shoulder dates (panes) on the new microsite. These shoulder dates usually do 15 days before the flight date and 15 days after so guests can easily view prices surrounding the date they chose.
Auro-carousel automatically renders with the carousel scrolled all the way to the left so the first items are displayed. However, it would be convenient if instead, we had an option to render with the selected pane centered on render.
This is due to the "selected pane" being the date you search for which will be on average the most middle element, however, if there are not 15 days before the date you searched it could be some random pane, not necessarily in the middle
Not centered:
Centered:
Describe the solution you'd like
Describe alternatives you've considered
Additional context