From c0b341672856aa7447f339688bba067e9868679d Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Fri, 12 May 2017 14:30:15 -0400 Subject: [PATCH] Add support for pre/post delay to TransitionTween. 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 --- src/interactions/TransitionTween.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/interactions/TransitionTween.swift b/src/interactions/TransitionTween.swift index 79b3ed3..aa2c2f4 100644 --- a/src/interactions/TransitionTween.swift +++ b/src/interactions/TransitionTween.swift @@ -57,6 +57,8 @@ public final class TransitionTween: Tween { public init(duration: CGFloat, forwardValues: [T], direction: ReactiveProperty, + delayBefore: CGFloat = 0, + delayAfter: CGFloat = 0, forwardKeyPositions: [CGFloat] = [], system: @escaping TweenToStream = coreAnimation, timeline: Timeline? = nil) { @@ -70,6 +72,7 @@ public final class TransitionTween: Tween { 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) } @@ -93,6 +96,7 @@ public final class TransitionTween: Tween { constraints: ConstraintApplicator? = 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) { @@ -108,4 +112,5 @@ public final class TransitionTween: Tween { private let direction: ReactiveProperty private let toggledValues: MotionObservable<[T]> private let toggledOffsets: MotionObservable<[CGFloat]> + private let toggledDelay: MotionObservable }