mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-13 09:50:17 +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
|
var visibility: ListViewItemNodeVisibility = .none
|
||||||
if visibilityRect.intersects(itemFrame) {
|
if visibilityRect.intersects(itemFrame) {
|
||||||
let itemContentFrame = itemNode.apparentContentFrame
|
let itemContentFrame = itemNode.apparentContentFrame
|
||||||
let full = itemContentFrame.minY >= visibilityRect.minY && itemContentFrame.maxY <= visibilityRect.maxY
|
let intersection = itemContentFrame.intersection(visibilityRect)
|
||||||
visibility = .visible(full)
|
let fraction = intersection.height / itemContentFrame.height
|
||||||
|
visibility = .visible(fraction)
|
||||||
}
|
}
|
||||||
var updateVisibility = false
|
var updateVisibility = false
|
||||||
if !onlyPositive {
|
if !onlyPositive {
|
||||||
|
|||||||
@ -52,7 +52,7 @@ public struct ListViewItemNodeLayout {
|
|||||||
|
|
||||||
public enum ListViewItemNodeVisibility: Equatable {
|
public enum ListViewItemNodeVisibility: Equatable {
|
||||||
case none
|
case none
|
||||||
case visible(Bool)
|
case visible(CGFloat)
|
||||||
|
|
||||||
public static func ==(lhs: ListViewItemNodeVisibility, rhs: ListViewItemNodeVisibility) -> Bool {
|
public static func ==(lhs: ListViewItemNodeVisibility, rhs: ListViewItemNodeVisibility) -> Bool {
|
||||||
switch lhs {
|
switch lhs {
|
||||||
@ -62,8 +62,8 @@ public enum ListViewItemNodeVisibility: Equatable {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .visible(full):
|
case let .visible(fraction):
|
||||||
if case .visible(full) = rhs {
|
if case .visible(fraction) = rhs {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user