Skip to content

Commit

Permalink
Populate sizeCache on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
zenangst committed Jan 3, 2018
1 parent d004f5c commit 26fabe1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/iOS-Exclusive/Classes/SpotsScrollView+iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ extension SpotsScrollView {
var yOffsetOfCurrentSubview: CGFloat = 0.0
let lastView = subviewsInLayoutOrder.last

for subview in subviewsInLayoutOrder {
for (offset, subview) in subviewsInLayoutOrder.enumerated() {
defer {
sizeCache[offset] = yOffsetOfCurrentSubview
}

if let scrollView = subview as? UIScrollView {
var frame = scrollView.frame
var contentOffset = scrollView.contentOffset
Expand Down Expand Up @@ -46,7 +50,6 @@ extension SpotsScrollView {

scrollView.frame = frame
scrollView.contentOffset = CGPoint(x: Int(contentOffset.x), y: Int(contentOffset.y))

yOffsetOfCurrentSubview += scrollView.contentSize.height
} else {
var frame = subview.frame
Expand Down

0 comments on commit 26fabe1

Please sign in to comment.