mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-10 19:42:21 +00:00
19 lines
607 B
Swift
19 lines
607 B
Swift
/// Presentation-only hysteresis. Being close enough to hide the latest
|
|
/// button never opts the reader back into tail following.
|
|
struct TranscriptBottomProximity {
|
|
private(set) var isAwayFromBottom = false
|
|
|
|
mutating func update(bottomDistance: Double, followsTail: Bool) {
|
|
guard !followsTail else {
|
|
isAwayFromBottom = false
|
|
return
|
|
}
|
|
let distance = max(0, bottomDistance)
|
|
if isAwayFromBottom {
|
|
if distance <= 24 { isAwayFromBottom = false }
|
|
} else if distance >= 80 {
|
|
isAwayFromBottom = true
|
|
}
|
|
}
|
|
}
|