spruce-ios icon indicating copy to clipboard operation
spruce-ios copied to clipboard

View sorting and animation timing should be separate concerns

Open ianterrell opened this issue 9 years ago • 1 comments

Currently sort functions are responsible for determining the timing information in an animation. I think that it would be cleaner to separate the two concepts. This would fix a few issues:

  1. Sorting and timing are orthogonal concerns, so separating them would let each piece have a single responsibility.
  2. Currently you can't use "inter-item time" based sort functions with a total duration timing. So it's not possible to have a random animation specified to last 3 seconds. Instead you'd have to do the math yourself knowing the total number of items ahead of time.
  3. Inter-item time is (hypothesis) less useful on average than total duration.

The API could be extended from:

yourView.spruce.animate([.fadeIn, .expand(.slightly)], sortFunction: sortFunction)

to something like

yourView.spruce.animate([.fadeIn, .expand(.slightly)], sortBy: sortFunction, duration: .total(3.0))

or

yourView.spruce.animate([.fadeIn, .expand(.slightly)], sortBy: sortFunction, duration: .withInterItemTime(0.1))

ianterrell avatar Mar 15 '17 16:03 ianterrell

how to hide with animate uiview???

hammas1993 avatar Jul 26 '19 18:07 hammas1993