Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Add support for pre/post delay to TransitionTween.
Browse files Browse the repository at this point in the history
Summary: This allows the transition tween to delay the tween based on the direction of the transition.

Reviewers: O2 Material Motion, O4 Material Apple platform reviewers, #material_motion, markwei

Reviewed By: O2 Material Motion, O4 Material Apple platform reviewers, #material_motion, markwei

Tags: #material_motion

Differential Revision: http://codereview.cc/D3220
  • Loading branch information
Jeff Verkoeyen committed May 12, 2017
1 parent fa28ef9 commit c0b3416
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/interactions/TransitionTween.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public final class TransitionTween<T>: Tween<T> {
public init(duration: CGFloat,
forwardValues: [T],
direction: ReactiveProperty<TransitionDirection>,
delayBefore: CGFloat = 0,
delayAfter: CGFloat = 0,
forwardKeyPositions: [CGFloat] = [],
system: @escaping TweenToStream<T> = coreAnimation,
timeline: Timeline? = nil) {
Expand All @@ -70,6 +72,7 @@ public final class TransitionTween<T>: Tween<T> {

self.toggledValues = direction.dedupe().rewrite([.backward: backwardValues, .forward: forwardValues])
self.toggledOffsets = direction.dedupe().rewrite([.backward: backwardKeyPositions, .forward: forwardKeyPositions])
self.toggledDelay = direction.dedupe().rewrite([.backward: delayAfter, .forward: delayBefore])
super.init(duration: duration, values: values, system: system, timeline: timeline)
}

Expand All @@ -93,6 +96,7 @@ public final class TransitionTween<T>: Tween<T> {
constraints: ConstraintApplicator<T>? = nil) {
let unlocked = createProperty(withInitialValue: false)
runtime.connect(direction.dedupe().rewriteTo(false), to: unlocked)
runtime.connect(toggledDelay, to: delay)
runtime.connect(toggledValues, to: values)
runtime.connect(toggledOffsets, to: offsets)
super.add(to: property, withRuntime: runtime) {
Expand All @@ -108,4 +112,5 @@ public final class TransitionTween<T>: Tween<T> {
private let direction: ReactiveProperty<TransitionDirection>
private let toggledValues: MotionObservable<[T]>
private let toggledOffsets: MotionObservable<[CGFloat]>
private let toggledDelay: MotionObservable<CGFloat>
}

0 comments on commit c0b3416

Please sign in to comment.