diff --git a/src/interactions/Tween.swift b/src/interactions/Tween.swift index 0524f21..7c843c8 100644 --- a/src/interactions/Tween.swift +++ b/src/interactions/Tween.swift @@ -32,6 +32,33 @@ public class Tween: Interaction, Togglable, Stateful { */ public let duration: ReactiveProperty + /** + The number of times the animation will repeat. + + If the repeatCount is 0, it is ignored. If both repeatDuration and repeatCount are specified the behavior is undefined. + + Setting this property to greatestFiniteMagnitude will cause the animation to repeat forever. + + See https://developer.apple.com/reference/quartzcore/camediatiming/1427666-repeatcount for more information. + */ + public let repeatCount: ReactiveProperty = createProperty("Tween.repeatCount", withInitialValue: 0) + + /** + The number of seconds the animation will repeat for. + + If the repeatDuration is 0, it is ignored. If both repeatDuration and repeatCount are specified the behavior is undefined. + + See https://developer.apple.com/reference/quartzcore/camediatiming/1427643-repeatduration for more information. + */ + public let repeatDuration: ReactiveProperty = createProperty("Tween.repeatDuration", withInitialValue: 0) + + /** + Will the animation play in the reverse upon completion. + + See https://developer.apple.com/reference/quartzcore/camediatiming/1427645-autoreverses for more information. + */ + public let autoreverses: ReactiveProperty = createProperty("Tween.autoreverses", withInitialValue: false) + /** The delay of the animation in seconds. */ @@ -137,6 +164,9 @@ public struct TweenShadow { public let state: ReactiveProperty public let duration: ReactiveProperty public let delay: ReactiveProperty + public let repeatCount: ReactiveProperty + public let repeatDuration: ReactiveProperty + public let autoreverses: ReactiveProperty public let values: ReactiveProperty<[T]> public let keyPositions: ReactiveProperty<[CGFloat]> public let timingFunctions: ReactiveProperty<[CAMediaTimingFunction]> @@ -146,6 +176,9 @@ public struct TweenShadow { self.enabled = tween.enabled self.state = tween._state self.duration = tween.duration + self.repeatCount = tween.repeatCount + self.repeatDuration = tween.repeatDuration + self.autoreverses = tween.autoreverses self.delay = tween.delay self.values = tween.values self.keyPositions = tween.keyPositions diff --git a/src/systems/coreAnimationTweenToStream.swift b/src/systems/coreAnimationTweenToStream.swift index e455972..ce52240 100644 --- a/src/systems/coreAnimationTweenToStream.swift +++ b/src/systems/coreAnimationTweenToStream.swift @@ -67,6 +67,9 @@ private func streamFromTween(_ tween: TweenShadow, configureEvent: @escapi } animation.beginTime = CFTimeInterval(tween.delay.value) animation.duration = CFTimeInterval(duration) + animation.repeatCount = Float(tween.repeatCount.value) + animation.repeatDuration = CFTimeInterval(tween.repeatDuration.value) + animation.autoreverses = tween.autoreverses.value let key = NSUUID().uuidString activeAnimations.insert(key)