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

Added delegate for know, when scrolling animation ends #40

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 Example/PickerView/ExamplePickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,8 @@ extension ExamplePickerViewController: PickerViewDelegate {
return customView
}

func pickerView(_ pickerView: PickerView, didEndScrollingRow row: Int, index: Int) {
print("Scroll animation ends in current Row \(row) and current Index \(index)")
}

}
8 changes: 7 additions & 1 deletion Pod/Classes/PickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import UIKit
@objc optional func pickerView(_ pickerView: PickerView, didTapRow row: Int, index: Int)
@objc optional func pickerView(_ pickerView: PickerView, styleForLabel label: UILabel, highlighted: Bool)
@objc optional func pickerView(_ pickerView: PickerView, viewForRow row: Int, index: Int, highlighted: Bool, reusingView view: UIView?) -> UIView?
@objc optional func pickerView(_ pickerView: PickerView, didEndScrollingRow row: Int, index: Int)
}

open class PickerView: UIView {
Expand Down Expand Up @@ -530,7 +531,6 @@ open class PickerView: UIView {
open func reloadPickerView() {
tableView.reloadData()
}

}

extension PickerView: UITableViewDataSource {
Expand Down Expand Up @@ -631,6 +631,12 @@ extension PickerView: UIScrollViewDelegate {
}

isScrolling = false

delegate?.pickerView?(self, didEndScrollingRow: currentSelectedRow, index: currentSelectedIndex)
}

open func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
delegate?.pickerView?(self, didEndScrollingRow: currentSelectedRow, index: currentSelectedIndex)
}

public func scrollViewDidScroll(_ scrollView: UIScrollView) {
Expand Down