diff --git a/Sources/Pow/Effects/SpinEffect.swift b/Sources/Pow/Effects/SpinEffect.swift index fd585a5..545e6f7 100644 --- a/Sources/Pow/Effects/SpinEffect.swift +++ b/Sources/Pow/Effects/SpinEffect.swift @@ -44,10 +44,11 @@ public extension AnyChangeEffect { /// - anchor: The location with a default of center that defines a point in 3D space about which the rotation is anchored. /// - anchorZ: The location with a default of 0 that defines a point in 3D space about which the rotation is anchored. /// - perspective: The relative vanishing point with a default of 1 / 6 for this rotation. + /// - perspective: An additional multipler you can provide to speed up the animation's runtime. /// - rate: The rate of the spin. - static func spin(axis: (x: CGFloat, y: CGFloat, z: CGFloat), anchor: UnitPoint = .center, anchorZ: CGFloat = 0, perspective: CGFloat = 1 / 6, rate: SpinRate = .default) -> AnyChangeEffect { + static func spin(axis: (x: CGFloat, y: CGFloat, z: CGFloat), anchor: UnitPoint = .center, anchorZ: CGFloat = 0, perspective: CGFloat = 1 / 6, multiplier speedBoost: CGFloat = 0.0, rate: SpinRate = .default) -> AnyChangeEffect { .simulation { change in - SpinSimulationModifier(impulseCount: change, axis: axis, anchor: anchor, anchorZ: anchorZ, perspective: perspective, rate: rate) + SpinSimulationModifier(impulseCount: change, axis: axis, anchor: anchor, anchorZ: anchorZ, perspective: perspective, additionalSpeed: speedBoost, rate: rate) } } } @@ -67,6 +68,8 @@ internal struct SpinSimulationModifier: ViewModifier, Simulative { var perspective: CGFloat + var additionalSpeed: CGFloat + var rate: AnyChangeEffect.SpinRate @State @@ -124,7 +127,7 @@ internal struct SpinSimulationModifier: ViewModifier, Simulative { if abs(angleVelocity.degrees) > 240 { newValue = angle.degrees + angleVelocity.degrees * step - newVelocity = angleVelocity.degrees * 0.99 + newVelocity = angleVelocity.degrees * (0.99 - self.additionalSpeed) targetAngle = .degrees((angle.degrees / 360.0).rounded(.up) * 360.0) } else if spring.response > 0 { (newValue, newVelocity) = spring.value(