Skip to content

Commit

Permalink
Add Padding to Layout Rect
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoolwinter committed Feb 21, 2024
1 parent f8aea77 commit 31f8bda
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,15 @@ public class TextLayoutManager: NSObject {
func layoutLines() { // swiftlint:disable:this function_body_length
guard let visibleRect = delegate?.visibleRect, !isInTransaction, let textStorage else { return }
CATransaction.begin()
let minY = max(visibleRect.minY, 0)
let maxY = max(visibleRect.maxY, 0)
let minY = max(visibleRect.minY - 350, 0) // +-350px for a bit padding while laying out lines.
let maxY = max(visibleRect.maxY + 350, 0)
let originalHeight = lineStorage.height
var usedFragmentIDs = Set<UUID>()
var forceLayout: Bool = needsLayout
var newVisibleLines: Set<TextLine.ID> = []
var yContentAdjustment: CGFloat = 0
var maxFoundLineWidth = maxLineWidth

var info = mach_timebase_info()
guard mach_timebase_info(&info) == KERN_SUCCESS else { return }
let start = mach_absolute_time()

// Layout all lines
for linePosition in lineStorage.linesStartingAt(minY, until: maxY) {
// Updating height in the loop may cause the iterator to be wrong
Expand Down

0 comments on commit 31f8bda

Please sign in to comment.