Files
divkit/client/ios/DivKit/DivVisibilityCounter.swift
pkurchatov d19df0fdff Restored DivVisibilityCounter visibility
commit_hash:fdfea1fb9ca1e09f63b75589abb4fb1037beef33
2025-01-16 18:23:47 +03:00

25 lines
496 B
Swift

import LayoutKit
@_spi(Internal)
public final class DivVisibilityCounter {
private var storage: [UIElementPath: UInt] = [:]
init() {}
func visibilityCount(for path: UIElementPath) -> UInt {
storage[path] ?? 0
}
func incrementCount(for path: UIElementPath) {
storage[path] = visibilityCount(for: path) + 1
}
public func reset() {
storage.removeAll()
}
public func reset(cardId: DivCardID) {
storage = storage.filter { $0.key.root != cardId.rawValue }
}
}