Skip to content

Commit

Permalink
Merge pull request #32 from wordpress-mobile/issue/30-editor-glitches…
Browse files Browse the repository at this point in the history
…-ios

Fixes an glitch due to contentSize refreshes during layout.
  • Loading branch information
diegoreymendez authored Jul 17, 2018
2 parents a1892be + 2795e25 commit 395b22b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ios/RNTAztecView/RCTAztecView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ import Foundation
class RCTAztecView: Aztec.TextView {
@objc var onContentSizeChange: RCTBubblingEventBlock? = nil

private var previousContentSize: CGSize = .zero

// MARK - View Height: Match to content height

override var contentSize: CGSize {
didSet {
contentSizeChanged()
}
override func layoutSubviews() {
super.layoutSubviews()

updateContentSizeInRN()
}

func contentSizeChanged() {
func updateContentSizeInRN() {
let newSize = contentSize

guard previousContentSize != newSize else {
return
}

previousContentSize = newSize
updateHeightToMatch(newSize.height)

guard let onContentSizeChange = onContentSizeChange else {
Expand Down

0 comments on commit 395b22b

Please sign in to comment.