Skip to content

Commit

Permalink
fix(#23): ios scroll insets not preserved when offset is applied
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz1913 committed Sep 26, 2021
1 parent cff6d92 commit 211aa0f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ios/AvoidSoftInputUtils.swift
Expand Up @@ -70,11 +70,14 @@ func computeSoftInputOffset(softInputHeight: CGFloat, firstResponder: UIView, co

func applyOffset(focusedInput: UIView, rootView: UIView, bottomOffset: CGFloat) -> MaybeScrollInsets {
if let scrollView = findScrollViewForFirstResponder(view: focusedInput, rootView: rootView) {
let contentInsets = UIEdgeInsets.init(top: 0.0, left: 0.0, bottom: bottomOffset, right: 0.0)
var newContentInset = scrollView.contentInset
newContentInset.bottom = max(bottomOffset, scrollView.contentInset.bottom)
var newScrollIndicatorInsets = scrollView.scrollIndicatorInsets
newScrollIndicatorInsets.bottom = max(bottomOffset, scrollView.scrollIndicatorInsets.bottom)
let scrollContentInset = scrollView.contentInset
let scrollIndicatorInsets = scrollView.scrollIndicatorInsets
scrollView.contentInset = contentInsets
scrollView.scrollIndicatorInsets = contentInsets
scrollView.contentInset = newContentInset
scrollView.scrollIndicatorInsets = newScrollIndicatorInsets
return MaybeScrollInsets(scrollContentInset: scrollContentInset, scrollIndicatorInsets: scrollIndicatorInsets)
}

Expand Down

0 comments on commit 211aa0f

Please sign in to comment.