Moveable
@MainActor
public protocol Moveable : AnyObject
This protocol declares methods and properties that must be adopted by custom motion classes in order to participate in the MotionMachine ecosystem. All standard MotionMachine motion classes conform to this protocol.
-
Stops a motion that is currently moving. (required)
Remark
When this method is called, a motion should only enter a stopped state if it currently moving.Declaration
Swift
@MainActor func stop()
-
Starts a motion that is currently stopped. (required)
Remark
This method can be chained when initializing the object.Note
When this method is called, a motion should only start moving if it is stopped.Declaration
Swift
@discardableResult @MainActor func start() -> Self
Return Value
A reference to the Moveable instance; used to method chain initialization methods when the Moveable instance is created.
-
Pauses a motion that is currently moving. (required)
Remark
When this method is called, a motion should only enter a paused state if it is currently moving.Declaration
Swift
@MainActor func pause()
-
Resumes a motion that is currently paused. (required)
Remark
When this method is called, a motion should only resume moving if it is currently paused.Declaration
Swift
@MainActor func resume()
-
Resets a motion to its initial state. Custom classes implementing this method must reset all relevant properties, including
totalProgress
. (required)Remark
This method is used byMoveable
collection classes to properly reset child motions for new movement cycles and when starting a motion again using thestart
method.Declaration
Swift
@MainActor func reset()
-
A
MotionState
enum which represents the current state of the motion operation. This state should be updated by the class implementing this protocol.Declaration
Swift
@MainActor var motionState: MotionState { get }
-
A Boolean which determines whether a motion operation, when it has moved to the ending value, should move from the ending value back to the starting value.
Remark
When set totrue
, the motion plays in reverse after completing a forward motion. In this state, a motion cycle represents the combination of the forward and reverse motions. The default value should befalse
.Declaration
Swift
@MainActor var reversing: Bool { get set }
-
A value between 0.0 and 1.0, which represents the current overall progress of a motion. This value should include all reversing and repeat motion cycles. (read-only)
Declaration
Swift
@MainActor var totalProgress: Double { get }
-
Provides a delegate for sending
MoveableStatus
updates from aMoveable
object. This property is used byMoveable
collection classes. Any customMoveable
classes must send status updates using this delegate.Warning
This delegate is only used byMoveable
objects to communicate with otherMoveable
objects. End-users should not assign their own delegate to this property. If you need status updates for aMoveable
object, please use the provided callback closures.Declaration
Swift
@MainActor var updateDelegate: MotionUpdateDelegate? { get set }
-
This method is called to prompt a motion class to update its current movement values.
Declaration
Swift
@MainActor func update(withTimeInterval currentTime: TimeInterval)
Parameters
currentTime
A timestamp that can be used in easing calculations.
-
cleanupResources()
Default implementationCalling this method on the conforming object should cleanup any resources to prepare for deallocation.
Default Implementation
Declaration
Swift
@MainActor func cleanupResources()