metafizzy / flickity

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

Draggable '>2' #745

Closed aaronstezycki closed 5 years ago

aaronstezycki commented 6 years ago

Sorry, hopefully a quick answer to a quick question. Does the new "draggable" option support more than >1 expression? i.e: can I put in >2 or >3 to only enable dragging when there 3 or more slides.

I have tried this, and currently it seems that only >1 is currently accepted as a value ? If this is the case (and that's fine) could we update the documentation just to make users aware that the number value is not changeable?

desandro commented 6 years ago

Does the new "draggable" option support more than >1 expression? i.e: can I put in >2 or >3 to only enable dragging when there 3 or more slides.

No, it does not.

could we update the documentation just to make users aware that the number value is not changeable?

My sense is that this would be a rare use-case. Adding more text that something isn't possible is counter-intuitive.

But I could be wrong. I'll leave this issue open in case.

aaronstezycki commented 6 years ago

Okay, this could be miss-interpretation about the use of 'draggable >1'.

My use case is I have a set of testimonial cards, up to 10 in a slider component. If there are less than 3 slider items, (because the slider at a desktop viewport can view 4 slides at full width) we get the same strange behaviour experienced in the original issue stated here #278 .

My fear is >1 only works when you have 2 or more showing on screen, but multiple scrollers could show differing amounts of scroll items on larger widths, with 3, 4 or 5 items, in which case the strange scroll behaviour continues if there are only 2 items.

I definitely think the value should be dependant on use case, and not limited to >1.

aaronstezycki commented 6 years ago

I suppose I could use the suggestion given in the original issue...

flkty = new Flickity(element, config)

if (flkty.cells.length < 4) {
    flkty.unbindDrag()
}
desandro commented 6 years ago

You could also use groupCells: true, so that cells are collected into a single slide that fit within the viewport. This may be the simplest option.

It also leads back to why previous/next buttons are still clickable even when previous/next cells are already in view. From https://github.com/metafizzy/flickity/issues/177#issuecomment-117680694

While the slider does not change, the selected cell does. This may be useful for accessibility, as it allows users to select a cell with buttons, rather than with mouse.

So your request is valid, but it's important to keep previous & next arrows working consistently for accessibility.

desandro commented 5 years ago

Closing this feature request as it hasn't received much interest.