metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.52k stars 605 forks source link

Selected cell isn't centered when `cellAlign: 'center'` #843

Closed elbamos closed 5 years ago

elbamos commented 5 years ago

In our app, the user can add and remove cells from the carousel, which starts empty. We do this by calling append (or prepend or insert, depending on how many cells are in the carousel), and then calling selectCell, and then reposition.

The behavior we'd like is for the currently selected cell to always be in the center of the screen, even when there aren't enough cells to fill the screen width.

The behavior we're seeing with cellAlign: center and wrapAround: true is that when the first cell is added, its properly centered. When the second cell is added, the cells move to be flush right, and the rightmost cell is selected. When the third cell is added, the cells are still flush right, but the newly added, selected cell is halfway cut-off by the edge of the window. After there are enough cells to fill the width of the screen, then the correct behavior begins.

How can we get the desired behavior with fewer cells than fill the screen? Thanks.

desandro commented 5 years ago

I'm sorry to see you're having trouble with Flickity. Could you provide a reduced test case? See Submitting Issues in the contributing guidelines.

coreybyrum7 commented 4 years ago

I'm having the same problem..

cellAlign: 'center' works as if cellAlign is set to left