Skip to content

View sorting and animation timing should be separate concerns #77

@ianterrell

Description

@ianterrell

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))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions