mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
25 lines
496 B
Swift
25 lines
496 B
Swift
import LayoutKit
|
|
|
|
@_spi(Internal)
|
|
public final class DivVisibilityCounter {
|
|
private var storage: [UIElementPath: UInt] = [:]
|
|
|
|
init() {}
|
|
|
|
public func reset() {
|
|
storage.removeAll()
|
|
}
|
|
|
|
public func reset(cardId: DivCardID) {
|
|
storage = storage.filter { $0.key.root != cardId.rawValue }
|
|
}
|
|
|
|
func visibilityCount(for path: UIElementPath) -> UInt {
|
|
storage[path] ?? 0
|
|
}
|
|
|
|
func incrementCount(for path: UIElementPath) {
|
|
storage[path] = visibilityCount(for: path) + 1
|
|
}
|
|
}
|