Back to Hero

HeroPlugin

docs/docsets/Hero.docset/Contents/Resources/Documents/Classes/HeroPlugin.html

1.6.47.7 KB
Original Source

HeroPlugin

open class HeroPlugin : NSObject, HeroPreprocessor, HeroAnimator

Undocumented

Show on GitHub

`

                hero
                `

Undocumented

Declaration

Swift

weak public var hero: HeroTransition!

Show on GitHub

`

                context
                `

Undocumented

Declaration

Swift

public var context: HeroContext! { get }

Show on GitHub

`

                requirePerFrameCallback
                `

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

Show on GitHub

`

                init()
                `

Undocumented

Declaration

Swift

public override required init()

Show on GitHub

`

                process(fromViews:toViews:)
                `

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

|

Show on GitHub

`

                canAnimate(view:appearing:)
                `

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.

Show on GitHub

`

                animate(fromViews:toViews:)
                `

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

Show on GitHub

`

                clean()
                `

Called when all animations are completed.

Should perform cleanup and release any reference

Declaration

Swift

open func clean()

Show on GitHub

`

                seekTo(timePassed:)
                `

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.

|

Show on GitHub

`

                resume(timePassed:reverse:)
                `

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

Show on GitHub

`

                apply(state:to:)
                `

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

|

Show on GitHub

`

                changeTarget(state:isDestination:to:)
                `

Undocumented

Declaration

Swift

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

Show on GitHub

`

                isEnabled
                `

Undocumented

Declaration

Swift

public static var isEnabled: Bool { get set }

Show on GitHub

`

                enable()
                `

Undocumented

Declaration

Swift

public static func enable()

Show on GitHub

`

                disable()
                `

Undocumented

Declaration

Swift

public static func disable()

Show on GitHub