Files
divkit/client/ios/DivKit/DivVisibilityCounter.swift
T
pkurchatov 0663870bf9 Swiftformat
commit_hash:52ce6e4a9f35a44ddef28565cec76ddaabdc2d08
2025-09-18 12:40:09 +03:00

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
}
}