Skip to content

Commit

Permalink
Add more documentation about ‘extra’ step
Browse files Browse the repository at this point in the history
  • Loading branch information
PimCoumans committed Jun 8, 2022
1 parent 6db1894 commit 3d30ad8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sample App/AnimationPlanner-Sample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ extension ViewController {
// Example of using a custom extension (defined further down) for a specific animation
.shake(view)
.extra {
// An `extra` step performs non-animating setup logic
// An extra step performs non-animating setup logic
// like adding another view to the mix
sneakyCopy = view.sneakyCopy()
}
Expand Down
7 changes: 5 additions & 2 deletions Sources/AnimationPlanner/AnimationPlanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import UIKit
/// Setting up your animation should be done with the following methods:
/// - ``delay(_:)`` adds a delay to the sequence. Delays are cumulative and are applied to the first actual animation to be performend.
/// - ``add(duration:options:timingFunction:animations:)`` adds an animation step to the sequence, providing a specific duration and optionally the `UIView.AnimationOptions` options and a `CAMediaTimingFunction` timing function.
/// - ``addSpring(duration:delay:damping:initialVelocity:options:animations:)`` adds a spring-based animation step with the expected damping and velocity values.
/// - ``extra(_:)`` adds an ‘extra’ step to prepare state before or between steps for the next animation or perform side-effects like triggering haptic feedback.
/// - ``addGroup(with:)`` creates a ``Group`` object to which multiple animations can be added that should be performed simultaneously.
///
/// - Note: Each animation is created right before it needs to be executed, so referencing values changed in previous steps is possible.
Expand Down Expand Up @@ -92,7 +94,7 @@ private protocol Animatable {

extension AnimationSequence {

/// Adds an animation to the sequence with all the expected animation parameters, adding the ability to use a timing function for the interpolation.
/// Adds an animation to the sequence with all the expected animation parameters, adding the ability to use a `CAMediaTimingFunction` timing function for the interpolation.
///
/// Adding each steps can by done in a chain, as this method returns `Self`
/// - Note: Adding a timing function will wrap the animation in a `CATransaction` commit
Expand All @@ -117,6 +119,7 @@ extension AnimationSequence {
/// Adds a spring-based animation to the animation sequence with all the expected animation parameters.
///
/// Adding each step in the sequence can by done in a chain, as this method returns `Self`
/// - Note: Timing curves aren‘t available in this method by design, the spring itself should do all the interpolating.
/// - Parameters:
/// - duration: Amount of time (in seconds) the animation should last
/// - delay: Amount of time (in seconds) the animation should wait to start
Expand Down Expand Up @@ -221,7 +224,7 @@ extension AnimationSequence {
return self
}

/// Adds an extra step where preparations or side-effects can be handled. Comparable to a 0-duration animation, without actually being
/// Adds an extra step where preparations or side-effects can be handled. Comparable to a 0-duration animation, without actually being
/// animated in a `UIView` animation closure.
/// - Parameter delay: Amount of time (in seconds) the handler should wait to be executed
/// - Parameter handler: Closure exectured at the specific time in the sequence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Use the extension method ``StepAnimatable/animateSteps(_:completion:)-8lxza`` (m
- Delay ``AnimationSequence/delay(_:)``: add a delay step that pauses the sequence for the given amount of seconds
- Animation ``AnimationSequence/add(duration:options:timingFunction:animations:)``: add an animation step with a desired duration and optionally animation options and a timing function
- Spring animation ``AnimationSequence/addSpring(duration:delay:damping:initialVelocity:options:animations:)``: add a spring-based animation step with the expected damping and velocity values. Timing curves aren‘t available in this method by design, the spring itself should do all the interpolating.
- Extra ``AnimationSequence/extra(_:)``: prepare state before or between steps for the next animation or perform side-effects like triggering haptic feedback.
- Group ``AnimationSequence/addGroup(with:)``: add an animation group (See ``AnimationSequence/Group``) where each animation added to this group animates at the same time

## Topics
Expand Down

0 comments on commit 3d30ad8

Please sign in to comment.