MotionSequence

MotionSequence moves a collection of objects conforming to the Moveable protocol in sequential order. MotionSequence provides a powerful and easy way of chaining together individual motions to create complex animations.

  • The delay, in seconds, before the sequence begins.

    Warning

    Setting this parameter after a sequence has begun has no effect.

    Declaration

    Swift

    public var delay: TimeInterval = 0.0
  • A Boolean which determines whether the sequence should repeat. When set to true, the sequence repeats for the number of times specified by the repeatCycles property. The default value is false.

    Note

    By design, setting this value to true without changing the repeatCycles property from its default value (0) will cause the sequence to repeat infinitely.

    Seealso

    repeatCycles

    Declaration

    Swift

    public var repeating: Bool = false
  • The number of complete sequence cycle operations to repeat.

    Remark

    This property is only used when repeating is set to true. Assigning REPEAT_INFINITE to this property signals an infinite amount of motion cycle repetitions. The default value is REPEAT_INFINITE.

    Seealso

    repeating

    Declaration

    Swift

    public var repeatCycles: UInt = REPEAT_INFINITE
  • An array of Moveable objects controlled by this MotionSequence object, determining each step of the sequence. (read-only)

    Remark

    The order of objects in this array represents the sequence order in which each will be moved.

    Declaration

    Swift

    private(set) public var steps: [Moveable] = []
  • A MotionDirection enum which represents the current direction of the motion operation. (read-only)

    Declaration

    Swift

    private(set) public var motionDirection: MotionDirection
  • A value between 0.0 and 1.0, which represents the current progress of a movement between two value destinations. (read-only)

    Remark

    Be aware that if this motion is reversing or repeating, this value will only represent one movement. For instance, if a Motion has been set to repeat once, this value will move from 0.0 to 1.0, then reset to 0.0 again as the new repeat cycle starts. Similarly, if a Motion is set to reverse, this progress will represent each movement; first in the forward direction, then again when reversing back to the starting values.

    Declaration

    Swift

    private(set) public var motionProgress: Double
  • A value between 0.0 and 1.0, which represents the current progress of a motion cycle. (read-only)

    Remark

    A cycle represents the total length of a one motion operation. If reversing is set to true, a cycle comprises two separate movements (the forward movement, which at completion will have a value of 0.5, and the movement in reverse which at completion will have a value of 1.0); otherwise a cycle is the length of one movement. Note that if repeating, each repetition will be a new cycle and thus the progress will reset to 0.0 for each repeat.

    Declaration

    Swift

    private(set) public var cycleProgress: Double
  • The amount of completed motion cycles. (read-only)

    Remark

    A cycle represents the total length of a one motion operation. If reversing is set to true, a cycle comprises two separate movements (the forward movement and the movement in reverse); otherwise a cycle is the length of one movement. Note that if repeating, each repetition will be a new cycle.

    Declaration

    Swift

    private(set) public var cyclesCompletedCount: UInt = 0
  • A value between 0.0 and 1.0, which represents the current overall progress of the sequence. This value should include all reversing and repeat motion cycles. (read-only)

    Remark

    If a sequence is not repeating, this value will be equivalent to the value of cycleProgress.

    Seealso

    cycleProgress

    Declaration

    Swift

    public var totalProgress: Double
  • Specifies that the MotionSequence’s child motions should reverse their movements back to their starting values after completing their forward movements. When each child motion should reverse is determined by the MotionSequence’s reversingMode.

    Important

    The previous state of reversing on any of this sequence’s Moveable objects will be overridden with the value you assign to this property!

    Declaration

    Swift

    public var reversing: Bool
  • A MotionState enum which represents the current movement state of the motion operation. (read-only)

    Declaration

    Swift

    private(set) public var motionState: MotionState
  • Provides a delegate for updates to a Moveable object’s status, used by Moveable collections.

    Declaration

    Swift

    public var updateDelegate: MotionUpdateDelegate?
  • A CollectionReversingMode enum which defines the behavior of a Moveable class when its reversing property is set to true. In the standard MotionMachine classes only MotionSequence currently uses this property to alter its behavior.

    Note

    While including this property in custom classes which implement the MoveableCollection protocol is required, implementation of behavior based on the property’s value is optional.

    Remark

    The default value is Sequential. Please see the documentation for CollectionReversingMode for more information on these modes.

    Declaration

    Swift

    public var reversingMode: CollectionReversingMode = .sequential
  • A concrete Tempo subclass that provides an update beat while a motion operation occurs.

    Remark

    By default, Motion will assign an instance of CATempo to this property, which uses CADisplayLink for interval updates.

    Declaration

    Swift

    public var tempo: Tempo?
  • This closure is called when a motion operation starts.

    Seealso

    start

    Declaration

    Swift

    @discardableResult public func started(_ closure: @escaping SequenceStarted) -> Self
  • This closure is called when a motion operation is stopped by calling the stop method.

    Seealso

    stop

    Declaration

    Swift

    @discardableResult public func stopped(_ closure: @escaping SequenceStopped) -> Self
  • This closure is called when a motion operation update occurs and this instance’s motionState is .Moving.

    Seealso

    update(withTimeInterval:)

    Declaration

    Swift

    @discardableResult public func updated(_ closure: @escaping SequenceUpdated) -> Self
  • This closure is called when a motion cycle has completed.

    Seealso

    repeating, cyclesCompletedCount

    Declaration

    Swift

    @discardableResult public func cycleRepeated(_ closure: @escaping SequenceRepeated) -> Self
  • This closure is called when the motionDirection property changes to .Reversing.

    Seealso

    motionDirection, reversing

    Declaration

    Swift

    @discardableResult public func reversed(_ closure: @escaping SequenceReversed) -> Self
  • This closure is called when calling the pause method on this instance causes a motion operation to pause.

    Seealso

    pause

    Declaration

    Swift

    @discardableResult public func paused(_ closure: @escaping SequencePaused) -> Self
  • This closure is called when calling the resume method on this instance causes a motion operation to resume.

    Seealso

    resume

    Declaration

    Swift

    @discardableResult public func resumed(_ closure: @escaping SequenceResumed) -> Self
  • This closure is called when a motion operation has completed (or when all motion cycles have completed, if repeating is set to true).

    Declaration

    Swift

    @discardableResult public func completed(_ closure: @escaping SequenceCompleted) -> Self
  • This notification closure is called when the sequence’s movement has advanced to its next sequence step.

    Declaration

    Swift

    @discardableResult public func stepCompleted(_ closure: @escaping SequenceStepped) -> Self
  • Initializer.

    Declaration

    Swift

    public init(steps: [Moveable]=[], options: MotionOptions?=MotionOptions.None)

    Parameters

    steps

    An array of Moveable objects the MotionSequence should control. The positions of the objects in the Array will determine the order in which the child motions should move.

    options

    An optional set of MotionsOptions.

  • Adds a sequence step to the end of the current sequence.

    Warning

    warning:

    • A NSInternalInconsistencyException will be raised if the provided object does not adopt the Moveable protocol.
    • This method should not be called after a MotionSequence has started moving.

    Declaration

    Swift

    @discardableResult public func add(_ sequenceStep: Moveable, useChildTempo: Bool = false) -> Self

    Parameters

    sequenceStep

    An object which adopts the Moveable protocol.

    useChildTempo

    When true, the child object should use its own tempo to update its motion progress, and thus the update method will not be called on the object by the MotionSequence instance. The default is false, meaning that the MotionSequence will use its own Tempo object to send updates to this child motion. This setting has no effect if the motion object does not conform to the TempoDriven protocol.

  • Adds an array of sequence steps to the current sequence.

    Note

    All objects added via this method which subscribe to the TempoDriven protocol will have their Tempo updates overriden. The MotionSequence will call the update method directly on all of them.

    Warning

    warning:

    • A NSInternalInconsistencyException will be raised if the provided object does not adopt the Moveable protocol.
    • This method should not be called after a MotionGroup has started moving.

    Declaration

    Swift

    @discardableResult public func add(_ steps: [Moveable]) -> Self

    Parameters

    steps

    An array of ‘Moveable` objects.

  • Removes the specified motion object from the sequence.

    Declaration

    Swift

    public func remove(_ sequenceStep: Moveable)

    Parameters

    sequenceStep

    The sequence step to remove.

  • Adds a delay before the motion operation will begin.

    Declaration

    Swift

    @discardableResult public func afterDelay(_ amount: TimeInterval) -> MotionSequence

    Parameters

    amount

    The number of seconds to wait.

    Return Value

    A reference to this MotionSequence instance, for the purpose of chaining multiple calls to this method.

  • Specifies that a motion cycle should repeat and the number of times it should do so. When no value is provided, the motion will repeat infinitely.

    Remark

    When this method is used there is no need to specify .Repeat in the options parameter of the init method.

    Seealso

    repeatCycles, repeating

    Declaration

    Swift

    @discardableResult public func repeats(_ numberOfCycles: UInt = REPEAT_INFINITE) -> MotionSequence

    Parameters

    numberOfCycles

    The number of motion cycles to repeat. The default value is REPEAT_INFINITE.

    Return Value

    A reference to this MotionSequence instance, for the purpose of chaining multiple calls to this method.

  • Specifies that the MotionSequence’s child motions should reverse their movements back to their starting values after completing their forward movements.

    Remark

    When this method is used there is no need to specify .Reverse in the options parameter of the init method.

    Seealso

    reversing, reversingMode

    Declaration

    Swift

    @discardableResult public func reverses(_ mode: CollectionReversingMode = .sequential) -> MotionSequence

    Parameters

    mode

    Defines the CollectionReversingMode used when reversing.

    Return Value

    A reference to this MotionSequence instance, for the purpose of chaining multiple calls to this method.

  • Either the sequence step which is currently moving, or the first sequence step if this instance’s motionState is currently Stopped.

    Declaration

    Swift

    public func currentStep() -> Moveable?

    Return Value

    The current sequence step.

  • Declaration

    Swift

    public func update(withTimeInterval currentTime: TimeInterval)
  • Declaration

    Swift

    @discardableResult public func start() -> Self
  • Declaration

    Swift

    public func stop()
  • Declaration

    Swift

    public func pause()
  • Declaration

    Swift

    public func resume()
  • Resets the sequence and all child motions to its initial state.

    Declaration

    Swift

    public func reset()