Introduce idea of a TimingFunction#83
Introduce idea of a TimingFunction#83Jackson Taylor (jacksontaylor13) wants to merge 4 commits intomasterfrom
Conversation
Given by issue #77, we introduce this idea of a TimingFunction now. This should allow any sort function to be considered a continuous or inter item function. This separates the notion that the two are related and brings TimingFunction to be an entirely new concept.
With the new `TimingFunction` protocol being added, we needed to make sure that it works properly with the example app. This will be a breaking change for some functions but we are going to submit another PR on top of this that should minimize the breaking nature of this change.
|
Still need to fix the unit tests, since the tests currently rely on |
Ian Terrell (ianterrell)
left a comment
There was a problem hiding this comment.
I only really gave it a cursory skim, but: I'm glad to see this change making it in! I think it's a good improvement in the concepts of an already great library. 👍
|
|
||
| } | ||
|
|
||
| public init(duration: TimeInterval) { |
There was a problem hiding this comment.
Rather than the default on the stored property you could consider a default value for this parameter and remove the empty init above.
|
|
||
| } | ||
|
|
||
| public init(interObjectDelay: TimeInterval) { |
There was a problem hiding this comment.
Ditto here with default parameter.
| /// - completion: a closure that is called upon the final animation completing. A `Bool` is passed into the closure letting you know if the animation has completed. **Note:** If you stop animations on the whole animating view, then `false` will be passed into the completion closure. However, if the final animation is allowed to proceed then `true` will be the value passed into the completion closure. | ||
| public func animate(withSortFunction sortFunction: SortFunction, prepare: PrepareHandler? = nil, animation: Animation, exclude: [UIView]? = nil, recursiveDepth: Int = 0, completion: CompletionHandler? = nil) { | ||
| var timedViews = sortFunction.timeOffsets(view: self.view, recursiveDepth: recursiveDepth) | ||
| public func animate(withSortFunction sortFunction: SortFunction, timingFunction: TimingFunction, prepare: PrepareHandler? = nil, animation: Animation, exclude: [UIView]? = nil, recursiveDepth: Int = 0, completion: CompletionHandler? = nil) { |
There was a problem hiding this comment.
The curse of good documentation — you need to update the parameter above.
|
|
||
| public func timeOffsets(view: UIView, recursiveDepth: Int) -> [TimedView] { | ||
| public func weights(forView view: UIView, recursiveDepth: Int) -> [WeightedView] { |
There was a problem hiding this comment.
weights(for view: UIView... is probably slightly more idiomatic naming.
|
|
||
| import Foundation | ||
|
|
||
| /// An internal struct that is used to relate a view with a time offset. This is used to determine when each view is set to animate. |
There was a problem hiding this comment.
The tiniest bit confusing to call it an "internal struct".
Add stock timing functions To make calling a timing function easier, there will now be an `enum` called `StockTimingFunction` that uses associated values to make creating a timing function super quick and easy.
Generated by 🚫 Danger |
Given by issue #77, we introduce this idea of a TimingFunction now. This should allow any sort function to be considered a continuous or inter item function. This separates the notion that the two are related and brings TimingFunction to be an entirely new concept.