ViewabilityCondition

open class ViewabilityCondition
extension ViewabilityCondition: ViewCondition

View condition with minimum percentage and minimum visible duration

  • Condition will be met when minimum view percentage is satisfied for minimum specified duration
  • Condition will fail when minimum view percentage condition fails after a previous success
  • Initializes ViewabilityCondition with provided minimum view percentage and minimum visible duration

    Declaration

    Swift

    public init(minPercentage: Float, minDuration: Int)

    Parameters

    minPercentage

    Minimum percentage of the view that needs to be visible to satisfy the condition

    • Ranges from 0 - 100

    minDuration

    Duration in milliseconds for which minimum view percentage should be satisfied to satisfy the condition

  • Called when the condition is met (satisfied)

    Subclasses should perform tasks that need to be done after condition is satisfied here

    Important

    This method needs to be overridden in subclasses, else it will throw a fatal error

    Note

    This method is always called on the main thread

    Declaration

    Swift

    open func conditionMet()
  • Called when the condition fails after previously being met

    Subclasses should perform tasks that need to be done after condition is failed here

    Important

    This method needs to be overridden in subclasses, else it will throw a fatal error

    Note

    This method is always called on the main thread

    Declaration

    Swift

    open func conditionFailed()
  • Declaration

    Swift

    public func evaluate(for state: ScrollState, viewPercentage: Float)
  • Declaration

    Swift

    public func reset()