Improve compile time.
This commit is contained in:
parent
9b77a81734
commit
934831b4bf
|
|
@ -114,8 +114,8 @@ class SKPagingScrollView: UIScrollView {
|
|||
func tilePages() {
|
||||
guard let browser = browser else { return }
|
||||
|
||||
let firstIndex = getFirstIndex()
|
||||
let lastIndex = getLastIndex()
|
||||
let firstIndex: Int = getFirstIndex()
|
||||
let lastIndex: Int = getLastIndex()
|
||||
|
||||
visiblePages
|
||||
.filter({ $0.tag - pageIndexTagOffset < firstIndex || $0.tag - pageIndexTagOffset < lastIndex })
|
||||
|
|
@ -125,19 +125,20 @@ class SKPagingScrollView: UIScrollView {
|
|||
page.removeFromSuperview()
|
||||
}
|
||||
|
||||
let visibleSet = Set(visiblePages)
|
||||
visiblePages = Array(visibleSet.subtract(recycledPages))
|
||||
let visibleSet: Set<SKZoomingScrollView> = Set(visiblePages)
|
||||
let visibleSetWithoutRecycled: Set<SKZoomingScrollView> = visibleSet.subtract(recycledPages)
|
||||
visiblePages = Array(visibleSetWithoutRecycled)
|
||||
|
||||
while recycledPages.count > 2 {
|
||||
recycledPages.removeFirst()
|
||||
}
|
||||
|
||||
for index in firstIndex...lastIndex {
|
||||
for index: Int in firstIndex...lastIndex {
|
||||
if visiblePages.filter({ $0.tag - pageIndexTagOffset == index }).count > 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
let page = SKZoomingScrollView(frame: frame, browser: browser)
|
||||
let page: SKZoomingScrollView = SKZoomingScrollView(frame: frame, browser: browser)
|
||||
page.frame = frameForPageAtIndex(index)
|
||||
page.tag = index + pageIndexTagOffset
|
||||
page.photo = browser.photos[index]
|
||||
|
|
@ -146,7 +147,7 @@ class SKPagingScrollView: UIScrollView {
|
|||
addSubview(page)
|
||||
|
||||
// if exists caption, insert
|
||||
if let captionView = createCaptionView(index) {
|
||||
if let captionView: SKCaptionView = createCaptionView(index) {
|
||||
captionView.frame = frameForCaptionView(captionView, index: index)
|
||||
captionView.alpha = browser.areControlsHidden() ? 0 : 1
|
||||
addSubview(captionView)
|
||||
|
|
@ -201,7 +202,7 @@ private extension SKPagingScrollView {
|
|||
return pageFrame
|
||||
}
|
||||
|
||||
private func createCaptionView(index: Int) -> SKCaptionView? {
|
||||
func createCaptionView(index: Int) -> SKCaptionView? {
|
||||
guard let photo = browser?.photoAtIndex(index) where photo.caption != nil else {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,16 +376,15 @@ internal extension SKPhotoBrowser {
|
|||
|
||||
internal extension SKPhotoBrowser {
|
||||
func panGestureRecognized(sender: UIPanGestureRecognizer) {
|
||||
guard let zoomingScrollView = pagingScrollView.pageDisplayedAtIndex(currentPageIndex) else {
|
||||
guard let zoomingScrollView: SKZoomingScrollView = pagingScrollView.pageDisplayedAtIndex(currentPageIndex) else {
|
||||
return
|
||||
}
|
||||
|
||||
backgroundView.hidden = true
|
||||
|
||||
let viewHeight = zoomingScrollView.frame.size.height
|
||||
let viewHalfHeight = viewHeight/2
|
||||
|
||||
var translatedPoint = sender.translationInView(self.view)
|
||||
let viewHeight: CGFloat = zoomingScrollView.frame.size.height
|
||||
let viewHalfHeight: CGFloat = viewHeight/2
|
||||
var translatedPoint: CGPoint = sender.translationInView(self.view)
|
||||
|
||||
// gesture began
|
||||
if sender.state == .Began {
|
||||
|
|
@ -399,8 +398,8 @@ internal extension SKPhotoBrowser {
|
|||
translatedPoint = CGPoint(x: firstX, y: firstY + translatedPoint.y)
|
||||
zoomingScrollView.center = translatedPoint
|
||||
|
||||
let minOffset = viewHalfHeight / 4
|
||||
let offset = 1 - (zoomingScrollView.center.y > viewHalfHeight
|
||||
let minOffset: CGFloat = viewHalfHeight / 4
|
||||
let offset: CGFloat = 1 - (zoomingScrollView.center.y > viewHalfHeight
|
||||
? zoomingScrollView.center.y - viewHalfHeight
|
||||
: -(zoomingScrollView.center.y - viewHalfHeight)) / viewHalfHeight
|
||||
|
||||
|
|
@ -423,7 +422,7 @@ internal extension SKPhotoBrowser {
|
|||
let finalX: CGFloat = firstX
|
||||
let finalY: CGFloat = viewHalfHeight
|
||||
|
||||
let animationDuration = Double(abs(velocityY) * 0.0002 + 0.2)
|
||||
let animationDuration: Double = Double(abs(velocityY) * 0.0002 + 0.2)
|
||||
|
||||
UIView.beginAnimations(nil, context: nil)
|
||||
UIView.setAnimationDuration(animationDuration)
|
||||
|
|
|
|||
Loading…
Reference in New Issue