mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-09 15:51:05 +00:00
ListView: added visible fraction value for visibility property
This commit is contained in:
parent
6e0355b632
commit
4658244e44
@ -2973,8 +2973,9 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
var visibility: ListViewItemNodeVisibility = .none
|
||||
if visibilityRect.intersects(itemFrame) {
|
||||
let itemContentFrame = itemNode.apparentContentFrame
|
||||
let full = itemContentFrame.minY >= visibilityRect.minY && itemContentFrame.maxY <= visibilityRect.maxY
|
||||
visibility = .visible(full)
|
||||
let intersection = itemContentFrame.intersection(visibilityRect)
|
||||
let fraction = intersection.height / itemContentFrame.height
|
||||
visibility = .visible(fraction)
|
||||
}
|
||||
var updateVisibility = false
|
||||
if !onlyPositive {
|
||||
|
||||
@ -52,7 +52,7 @@ public struct ListViewItemNodeLayout {
|
||||
|
||||
public enum ListViewItemNodeVisibility: Equatable {
|
||||
case none
|
||||
case visible(Bool)
|
||||
case visible(CGFloat)
|
||||
|
||||
public static func ==(lhs: ListViewItemNodeVisibility, rhs: ListViewItemNodeVisibility) -> Bool {
|
||||
switch lhs {
|
||||
@ -62,8 +62,8 @@ public enum ListViewItemNodeVisibility: Equatable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .visible(full):
|
||||
if case .visible(full) = rhs {
|
||||
case let .visible(fraction):
|
||||
if case .visible(fraction) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user