Skip to content

Commit

Permalink
Properly update on change of autoIgnoreContentInset
Browse files Browse the repository at this point in the history
  • Loading branch information
nighthawk committed Mar 13, 2024
1 parent 42a4802 commit 39e2196
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/TGCardViewController/cards/TGCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,15 @@ open class TGCard: UIResponder, TGPreferrableView {

public var autoIgnoreContentInset: Bool = false {
didSet {
if autoIgnoreContentInset, let scrollView = cardView?.contentScrollView, scrollView.contentOffset.y < 0 {
guard autoIgnoreContentInset != oldValue, title.isExtended, let cardView, let scrollView = cardView.contentScrollView else { return }

if autoIgnoreContentInset, scrollView.contentOffset.y < 0 {
scrollView.contentOffset.y = 0
cardView.showSeparator(true, offset: 0)

} else if !autoIgnoreContentInset, scrollView.contentOffset.y > cardView.headerHeight * -1 {
scrollView.contentOffset.y = cardView.headerHeight * -1
cardView.showSeparator(true, offset: cardView.headerHeight * -1)
}
}
}
Expand Down

0 comments on commit 39e2196

Please sign in to comment.