[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce idea of a TimingFunction #83

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jacksontaylor13
Copy link
Contributor
@jacksontaylor13 jacksontaylor13 commented Mar 20, 2017

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.

  • Update changelog

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.
@jacksontaylor13
Copy link
Contributor Author

Still need to fix the unit tests, since the tests currently rely on SortFunction's returning a TimedView

Copy link
@ianterrell ianterrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here with default parameter.

@@ -52,8 +52,9 @@ public extension Spruce {
/// - exclude: an array of views that the animation should skip over
/// - recursiveDepth: an int describing how deep into the view hiearchy the subview search should go, defaults to 0
/// - 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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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] {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@ci-wta
Copy link
ci-wta commented Mar 21, 2017
1 Error
🚫 Any changes to the Spruce library need to be documented in the Changelog
1 Warning
⚠️ Big PR

Generated by 🚫 Danger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants