Skip to content

Commit

Permalink
Update UIScrollViewDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
hcn1519 committed Jan 9, 2018
1 parent 5f06c24 commit 2b818f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions MyTileImageViewer/TileImageView/TileImageScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import UIKit

open class TileImageScrollView: UIScrollView {

var tileImageScrollViewDelegate: TileImageScrollViewDelegate?

private var contentView: TileImageContentView?
weak var dataSource: TileImageViewDataSource?
private var currentBounds = CGSize.zero
Expand All @@ -41,6 +43,8 @@ open class TileImageScrollView: UIScrollView {

self.dataSource = dataSource

self.tileImageScrollViewDelegate = dataSource.delegate

let tileImageView = TileImageView(dataSource: dataSource)
tileImageView.dataSource = dataSource

Expand Down Expand Up @@ -99,6 +103,15 @@ extension TileImageScrollView: UIScrollViewDelegate {
let topY = max((bounds.height - contentSize.height)/2, 0)
contentView?.frame.origin = CGPoint(x: topX, y: topY)
}

public func scrollViewDidScroll(_ scrollView: UIScrollView) {
tileImageScrollViewDelegate?.didScroll(scrollView: self)
}

public func scrollViewDidZoom(_ scrollView: UIScrollView) {
tileImageScrollViewDelegate?.didZoom(scrollView: self)
}

}

// MARK: DoubleTappable
Expand Down
8 changes: 8 additions & 0 deletions MyTileImageViewer/TileImageView/TileImageViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@

import UIKit

public protocol TileImageScrollViewDelegate {
func didScroll(scrollView: TileImageScrollView)
func didZoom(scrollView: TileImageScrollView)
}

public protocol TileImageViewDataSource: class {

var delegate: TileImageScrollViewDelegate? { get set }

// full Image size
var originalImageSize: CGSize { get set }

Expand Down Expand Up @@ -43,3 +50,4 @@ extension TileImageViewDataSource {
return self.originalImageSize
}
}

2 changes: 1 addition & 1 deletion StorytellingKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'StorytellingKit'
s.version = '0.1.1'
s.version = '0.1.2'
s.summary = 'High Quality Image ScrollView with storytelling contents.'

s.description = <<-DESC
Expand Down

0 comments on commit 2b818f5

Please sign in to comment.