Skip to content

Commit

Permalink
replace optional force unwrapping with more safe way (HeroTransitions…
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-xdyang authored and kuyazee committed Jan 2, 2020
1 parent 9631cb9 commit e4ebbb0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Sources/Animator/HeroCoreAnimationViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ extension CALayer {
}()

@objc dynamic func hero_add(anim: CAAnimation, forKey: String?) {
if CALayer.heroAddedAnimations != nil {
let copiedAnim = anim.copy() as! CAAnimation
copiedAnim.delegate = nil // having delegate resulted some weird animation behavior
CALayer.heroAddedAnimations!.append((self, forKey!, copiedAnim))
hero_add(anim: anim, forKey: forKey)
} else {
hero_add(anim: anim, forKey: forKey)
if let animationKey = forKey,
CALayer.heroAddedAnimations != nil,
let copiedAnim = anim.copy() as? CAAnimation {
copiedAnim.delegate = nil // having delegate resulted some weird animation behavior
CALayer.heroAddedAnimations?.append((self, animationKey, copiedAnim))
}
hero_add(anim: anim, forKey: forKey)
}
}

Expand Down

0 comments on commit e4ebbb0

Please sign in to comment.