JJItemAnimationConfiguration

@objc
public class JJItemAnimationConfiguration : NSObject

Item animation configuration

  • Animation settings for opening animation. Default values are:

    • duration = 0.3
    • dampingRatio = 0.55
    • initialVelocity = 0.3
    • interItemDelay = 0.1

    Declaration

    Swift

    @objc
    public lazy var opening: JJAnimationSettings { get set }
  • Animation settings for closing animation. Default values are:

    • duration = 0.3
    • dampingRatio = 0.6
    • initialVelocity = 0.8
    • interItemDelay = 0.1

    Declaration

    Swift

    @objc
    public lazy var closing: JJAnimationSettings { get set }
  • Defines the layout of the acton items when opened. Default is a layout in a vertical line with 12 points inter item spacing

    Declaration

    Swift

    @objc
    public var itemLayout: JJItemLayout
  • Configures the items before opening. The change from open to closed state is animated. Default is a scale by factor 0.4 and item.alpha = 0.

    Declaration

    Swift

    @objc
    public var closedState: JJItemPreparation
  • Configures the items for open state. The change from open to closed state is animated. Default is item.transform = .identity and item.alpha = 1.

    Declaration

    Swift

    @objc
    public var openState: JJItemPreparation

JJItemAnimationConfiguration

  • Returns an item animation configuration with

    • itemLayout = .verticalLine()
    • closedState = .scale()

    Declaration

    Swift

    static func popUp(withInterItemSpacing interItemSpacing: CGFloat = 12,
                      firstItemSpacing: CGFloat = 0) -> JJItemAnimationConfiguration

    Parameters

    interItemSpacing

    The distance between two adjacent items. Default is 12.

    firstItemSpacing

    The distance between the action button and the first action item. When firstItemSpacing is 0 or less interItemSpacing is used instead. Default is 0.

    Return Value

    An item animation configuration object.

  • Returns an item animation configuration with

    • itemLayout = .verticalLine()
    • closedState = .horizontalOffset()

    Declaration

    Swift

    static func slideIn(withInterItemSpacing interItemSpacing: CGFloat = 12,
                        firstItemSpacing: CGFloat = 0) -> JJItemAnimationConfiguration

    Parameters

    interItemSpacing

    The distance between two adjacent items. Default is 12.

    firstItemSpacing

    The distance between the action button and the first action item. When firstItemSpacing is 0 or less interItemSpacing is used instead. Default is 0.

    Return Value

    An item animation configuration object.

  • Returns an item animation configuration with

    • itemLayout = .circular()
    • closedState = .scale()

    Declaration

    Swift

    static func circularPopUp(withRadius radius: CGFloat = 100,
                              angleForItem: @escaping JJItemAngle = JJItemAnimationConfiguration.angleForItem)
        -> JJItemAnimationConfiguration

    Parameters

    radius

    The distance between the center of an item and the center of the button itself.

    angleForItem

    A closure that calculates the angle for each item in a floating action button. Default is JJItemAnimationConfiguration.angleForItem.

    Return Value

    An item animation configuration object.

  • Returns an item animation configuration with

    • itemLayout = .circular()
    • closedState = .circularOffset()

    Declaration

    Swift

    static func circularSlideIn(withRadius radius: CGFloat = 100,
                                angleForItem: @escaping JJItemAngle = JJItemAnimationConfiguration.angleForItem)
        -> JJItemAnimationConfiguration

    Parameters

    radius

    The distance between the center of an item and the center of the button itself.

    angleForItem

    A closure that calculates the angle for each item in a floating action button. Default is JJItemAnimationConfiguration.angleForItem.

    Return Value

    An item animation configuration object.

Helper

  • Calculates the angle for the item at the specified index in the floating action button.

    Declaration

    Swift

    @objc
    static func angleForItem(at index: Int, numberOfItems: Int, actionButton: JJFloatingActionButton) -> CGFloat

    Parameters

    index

    The index of the item.

    numberOfItems

    The total number of items in the floating action button.

    actionButton

    The floating action button.

    Return Value

    The angle in radians for the item at the specified index.