Skip to content

Commit

Permalink
remove all animation before reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
lkzhao committed May 1, 2024
1 parent cde93a1 commit a88e30f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/UIComponent/Core/ComponentView/ReuseManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public enum ReuseStrategy: Equatable {
case key(String)
}

public protocol ReuseableView: UIView {
func prepareForReuse()
}

/// `ReuseManager` is a class that manages the reuse of `UIView` objects to improve performance.
/// It stores reusable views in a dictionary and provides methods to enqueue and dequeue these views.
/// It also handles the cleanup of views that are no longer needed.
Expand Down Expand Up @@ -74,6 +78,8 @@ open class ReuseManager: NSObject {
) -> T {
let queuedView = reusableViews[identifier]?.popLast() as? T
let view = queuedView ?? defaultView()
view.layer.removeAllAnimations()
(view as? ReuseableView)?.prepareForReuse()
if !removeFromSuperviewWhenReuse {
view.isHidden = false
}
Expand Down

0 comments on commit a88e30f

Please sign in to comment.