Skip to content

Commit

Permalink
Merge pull request #792 from hyperoslo/implement/size-cache-for-ios
Browse files Browse the repository at this point in the history
Populate sizeCache on iOS
  • Loading branch information
zenangst authored Jan 3, 2018
2 parents d004f5c + 26fabe1 commit 2109e77
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 2109e77

Please sign in to comment.