mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 11:50:56 +00:00
Fix item list scrolling for touches outside section blocks
This commit is contained in:
parent
2c52ee06de
commit
95b4d581cd
@ -184,6 +184,8 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
|||||||
|
|
||||||
public final var keepMinimalScrollHeightWithTopInset: CGFloat?
|
public final var keepMinimalScrollHeightWithTopInset: CGFloat?
|
||||||
|
|
||||||
|
public final var itemNodeHitTest: ((CGPoint) -> Bool)?
|
||||||
|
|
||||||
public final var stackFromBottom: Bool = false
|
public final var stackFromBottom: Bool = false
|
||||||
public final var stackFromBottomInsetItemFactor: CGFloat = 0.0
|
public final var stackFromBottomInsetItemFactor: CGFloat = 0.0
|
||||||
public final var limitHitTestToNodes: Bool = false
|
public final var limitHitTestToNodes: Bool = false
|
||||||
@ -3876,8 +3878,14 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.touchesPosition = touchesPosition
|
self.touchesPosition = touchesPosition
|
||||||
self.selectionTouchLocation = touches.first!.location(in: self.view)
|
|
||||||
|
|
||||||
|
var processSelection = true
|
||||||
|
if let itemNodeHitTest = self.itemNodeHitTest, !itemNodeHitTest(touchesPosition) {
|
||||||
|
processSelection = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if processSelection {
|
||||||
|
self.selectionTouchLocation = touches.first!.location(in: self.view)
|
||||||
self.selectionTouchDelayTimer?.invalidate()
|
self.selectionTouchDelayTimer?.invalidate()
|
||||||
self.selectionLongTapDelayTimer?.invalidate()
|
self.selectionLongTapDelayTimer?.invalidate()
|
||||||
self.selectionLongTapDelayTimer = nil
|
self.selectionLongTapDelayTimer = nil
|
||||||
@ -3936,7 +3944,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
|||||||
}, selector: #selector(ListViewTimerProxy.timerEvent), userInfo: nil, repeats: false)
|
}, selector: #selector(ListViewTimerProxy.timerEvent), userInfo: nil, repeats: false)
|
||||||
self.selectionTouchDelayTimer = timer
|
self.selectionTouchDelayTimer = timer
|
||||||
RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
|
RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
|
||||||
|
}
|
||||||
super.touchesBegan(touches, with: event)
|
super.touchesBegan(touches, with: event)
|
||||||
|
|
||||||
self.updateScroller(transition: .immediate)
|
self.updateScroller(transition: .immediate)
|
||||||
|
|||||||
@ -238,7 +238,9 @@ open class ItemListControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
|
|
||||||
self.listNode = ListView()
|
self.listNode = ListView()
|
||||||
self.leftOverlayNode = ASDisplayNode()
|
self.leftOverlayNode = ASDisplayNode()
|
||||||
|
self.leftOverlayNode.isUserInteractionEnabled = false
|
||||||
self.rightOverlayNode = ASDisplayNode()
|
self.rightOverlayNode = ASDisplayNode()
|
||||||
|
self.rightOverlayNode.isUserInteractionEnabled = false
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@ -303,6 +305,14 @@ open class ItemListControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.listNode.itemNodeHitTest = { [weak self] point in
|
||||||
|
if let strongSelf = self {
|
||||||
|
return point.x > strongSelf.leftOverlayNode.frame.maxX && point.x < strongSelf.rightOverlayNode.frame.minX
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let previousState = Atomic<ItemListNodeState?>(value: nil)
|
let previousState = Atomic<ItemListNodeState?>(value: nil)
|
||||||
self.transitionDisposable.set(((state
|
self.transitionDisposable.set(((state
|
||||||
|> map { presentationData, stateAndArguments -> ItemListNodeTransition in
|
|> map { presentationData, stateAndArguments -> ItemListNodeTransition in
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user