mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 23:54:32 +00:00
Fix: Hover Gesture
This commit is contained in:
parent
40cd7d0d92
commit
c52fe73331
2 changed files with 19 additions and 8 deletions
|
|
@ -76,7 +76,11 @@ private struct ScrollMonitor: NSViewRepresentable {
|
|||
private var active = false
|
||||
private let noiseThreshold: CGFloat = 0.2
|
||||
private weak var observedView: NSView?
|
||||
private let hoverInset: CGFloat = 14
|
||||
/// Small vertical inset so scroll gestures fire when the cursor
|
||||
/// "kisses" the very top of the screen inside the physical notch
|
||||
/// area. Kept at zero horizontally to avoid unwanted hover opens
|
||||
/// from the sides.
|
||||
private let verticalEdgeInset: CGFloat = 4
|
||||
private var lastEventTimestamp: TimeInterval = 0
|
||||
|
||||
init(direction: PanDirection, threshold: CGFloat, action: @escaping (CGFloat, NSEvent.Phase) -> Void) {
|
||||
|
|
@ -154,7 +158,12 @@ private struct ScrollMonitor: NSViewRepresentable {
|
|||
|
||||
let windowPoint = window.convertPoint(fromScreen: screenPoint)
|
||||
let localPoint = view.convert(windowPoint, from: nil)
|
||||
let hitArea = view.bounds.insetBy(dx: -hoverInset, dy: -hoverInset)
|
||||
|
||||
// Extend the hit area vertically by a few points so the cursor
|
||||
// at the very top screen edge (kissing the notch) still triggers
|
||||
// scroll gestures. No horizontal extension to prevent false opens
|
||||
// from the sides of the notch.
|
||||
let hitArea = view.bounds.insetBy(dx: 0, dy: -verticalEdgeInset)
|
||||
return hitArea.contains(localPoint)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue