Created
November 21, 2021 16:47
-
-
Save umurgdk/b8df7aad275a73130dbe2c9551e4da43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FlippedClipView: NSClipView { | |
var stickyView: NSView? | |
var trailingConstraint: NSLayoutConstraint? | |
override var isFlipped: Bool { true } | |
override func layout() { | |
super.layout() | |
if trailingConstraint == nil, let scrollView = enclosingScrollView, let stickyView = stickyView { | |
trailingConstraint = stickyView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor, constant: 0) | |
trailingConstraint?.isActive = true | |
} | |
} | |
override var documentRect: NSRect { | |
let rect = super.documentRect | |
trailingConstraint?.constant = bounds.origin.x | |
return rect | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment