spruce-ios
spruce-ios copied to clipboard
View sorting and animation timing should be separate concerns
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:
- Sorting and timing are orthogonal concerns, so separating them would let each piece have a single responsibility.
- 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.
- 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))
how to hide with animate uiview???