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 }