Skip to content

Commit

Permalink
remember animation status, recover animation only when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
cshen committed Aug 28, 2018
1 parent 6a59d76 commit c027c3e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion APNGKit/APNGImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ open class APNGImageView: APNGView {
/// A Bool value indicating whether the animation is running.
open fileprivate(set) var isAnimating: Bool

/// A Bool value indicating whether the animation was running before app resigned active
private var wasAnimating: Bool = false

/// A Bool value indicating whether the animation should be
/// started automatically after an image is set. Default is false.
open var autoStartAnimation: Bool {
Expand Down Expand Up @@ -253,14 +256,17 @@ open class APNGImageView: APNGView {
Stop animation when app send to background.
*/
@objc private func appWillResignActive() {
wasAnimating = isAnimating
stopAnimating()
}

/**
Start animation when app become active.
*/
@objc func appDidBecomeActive() {
startAnimating()
if wasAnimating {
startAnimating()
}
}

/**
Expand Down

0 comments on commit c027c3e

Please sign in to comment.