Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add func dg_startLoading() #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ public extension UIScrollView {
public func dg_stopLoading() {
pullToRefreshView?.stopLoading()
}

public func dg_startLoading() {
pullToRefreshView?.startLoading()
}
}

// MARK: -
Expand Down
12 changes: 12 additions & 0 deletions DGElasticPullToRefresh/DGElasticPullToRefreshView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ open class DGElasticPullToRefreshView: UIView {
if previousValue == .dragging && newValue == .animatingBounce {
loadingView?.startAnimating()
animateBounce()
} else if previousValue == .stopped && newValue == .animatingBounce {
loadingView?.setPullProgress(1.0)
loadingView?.startAnimating()
animateBounce()
} else if newValue == .loading && actionHandler != nil {
actionHandler()
} else if newValue == .animatingToStopped {
Expand Down Expand Up @@ -214,6 +218,14 @@ open class DGElasticPullToRefreshView: UIView {
state = .animatingToStopped
}

func startLoading() {
if state != .stopped {
return
} else {
state = .animatingBounce
}
}

// MARK: Methods (Private)

fileprivate func isAnimating() -> Bool {
Expand Down
5 changes: 5 additions & 0 deletions DGElasticPullToRefreshExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class ViewController: UIViewController {
tableView.dg_removePullToRefresh()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

tableView.dg_startLoading()
}
}

// MARK: -
Expand Down