HeroPlugin

open class HeroPlugin : NSObject, HeroPreprocessor, HeroAnimator

Undocumented

  • Undocumented

    Declaration

    Swift

    weak public var hero: HeroTransition!
  • Undocumented

    Declaration

    Swift

    public var context: HeroContext! { get }
  • Determines whether or not to receive seekTo callback on every frame.

    Default is false.

    When requirePerFrameCallback is false, the plugin needs to start its own animations inside animate & resume The seekTo method is only being called during an interactive transition.

    When requirePerFrameCallback is true, the plugin will receive seekTo callback on every animation frame. Hence it is possible for the plugin to do per-frame animations without implementing animate & resume

    Declaration

    Swift

    open var requirePerFrameCallback: Bool
  • Undocumented

    Declaration

    Swift

    public override required init()
  • Called before any animation. Override this method when you want to preprocess modifiers for views

    To check a view’s modifiers:

    context[view]
    context[view, "modifierName"]
    

    To set a view’s modifiers:

    context[view] = [("modifier1", ["parameter1"]), ("modifier2", [])]
    context[view, "modifier1"] = ["parameter1", "parameter2"]
    

    Declaration

    Swift

    open func process(fromViews: [UIView], toViews: [UIView])

    Parameters

    context

    object holding all parsed and changed modifiers,

    fromViews

    A flattened list of all views from source ViewController

    toViews

    A flattened list of all views from destination ViewController

  • Declaration

    Swift

    open func canAnimate(view: UIView, appearing: Bool) -> Bool

    Parameters

    context

    object holding all parsed and changed modifiers,

    view

    the view to check whether or not the plugin can handle the animation

    appearing

    true if the view is appearing(i.e. a view in destination ViewController) If return true, Hero won’t animate and won’t let any other plugins animate this view. The view will also be hidden automatically during the animation.

    Return Value

    return true if the plugin can handle animating the view.

  • Perform the animation.

    Note: views in fromViews & toViews are hidden already. Unhide then if you need to take snapshots.

    Declaration

    Swift

    open func animate(fromViews: [UIView], toViews: [UIView]) -> TimeInterval

    Parameters

    context

    object holding all parsed and changed modifiers,

    fromViews

    A flattened list of all views from source ViewController (filtered by canAnimate)

    toViews

    A flattened list of all views from destination ViewController (filtered by canAnimate)

    Return Value

    The duration needed to complete the animation

  • Called when all animations are completed.

    Should perform cleanup and release any reference

    Declaration

    Swift

    open func clean()
  • For supporting interactive animation only.

    This method is called when an interactive animation is in place The plugin should pause the animation, and seek to the given progress

    Declaration

    Swift

    open func seekTo(timePassed: TimeInterval)

    Parameters

    timePassed

    time of the animation to seek to.

  • For supporting interactive animation only.

    This method is called when an interactive animation is ended The plugin should resume the animation.

    • timePassed: will be the same value since last seekTo
    • reverse: a boolean value indicating whether or not the animation should reverse

    Declaration

    Swift

    open func resume(timePassed: TimeInterval, reverse: Bool) -> TimeInterval
  • For supporting interactive animation only.

    This method is called when user wants to override animation modifiers during an interactive animation

    Declaration

    Swift

    open func apply(state: HeroTargetState, to view: UIView)

    Parameters

    state

    the target state to override

    view

    the view to override

  • Undocumented

    Declaration

    Swift

    open func changeTarget(state: HeroTargetState, isDestination: Bool, to view: UIView)
  • Undocumented

    Declaration

    Swift

    public static var isEnabled: Bool { get set }
  • Undocumented

    Declaration

    Swift

    public static func enable()
  • Undocumented

    Declaration

    Swift

    public static func disable()