-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace KVO for measurer with bounds observer
- Loading branch information
Showing
3 changed files
with
25 additions
and
32 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
modules/keyboard-avoiding-view/ios/BoundsObservableView.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
public class BoundsObservableView: UIView { | ||
public weak var boundsDelegate: ViewBoundsObserving? | ||
private var previousBounds: CGRect = .zero | ||
|
||
public override func layoutSubviews() { | ||
if bounds != previousBounds { | ||
boundsDelegate?.boundsDidChange(self, from: previousBounds) | ||
previousBounds = bounds | ||
} | ||
|
||
super.layoutSubviews() | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public protocol ViewBoundsObserving: AnyObject { | ||
func boundsDidChange(_ view: BoundsObservableView, from previousBounds: CGRect) | ||
} |