vertical-collection icon indicating copy to clipboard operation
vertical-collection copied to clipboard

Feature Request: Move 2 items at a time.

Open ming-codes opened this issue 7 years ago • 3 comments

Either as default or as a configurable option.

A common pattern in table is striped rows. Striped rows are commonly implemented as :nth-child(odd) selector. Currently, vertical-collection moves 1 item at a time. When this happens, the row strips shifts, creating a bad experience.

The current workaround is to precompute the even/odd rows and attach additional class on the row to preserve the strips.

ming-codes avatar Apr 25 '18 17:04 ming-codes

If possible and not overly / unnecessarily complicated, adding the ability to group updates in batches of variable size (not only one and two, but n) might be even better.

buschtoens avatar Apr 25 '18 17:04 buschtoens

You don't need to pre-compute if you use index to do it, although I generally agree that using :nth-child(odd) is nice.

runspired avatar Apr 25 '18 21:04 runspired

@runspired: You don't need to pre-compute if you use index to do it

+1. I have solved it like this:

    <VerticalCollection
      as |item index|
    >
      <tr
        class="_{{oddity index}}"
      >
        <Whatever @item=item>
      </tr>
    </VerticalCollection>
// helper
function oddity([value]: [number] /*, hash */): 'even' | 'odd' {
  return value % 2 === 0 ? 'even' : 'odd';
}
tr {
  &._odd {
    background: white;
  }
  &._even {
    background: lightgray;
  }
}

lolmaus avatar Jan 15 '21 06:01 lolmaus