Skip to content

Commit

Permalink
Merge pull request #77 from shenchenchester/master
Browse files Browse the repository at this point in the history
remember animation status, recover animation only when necessary
  • Loading branch information
onevcat committed Sep 9, 2018
2 parents 38847e7 + c027c3e commit daf0744
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 daf0744

Please sign in to comment.