evgenyneu / Auk

An image slideshow for iOS written in Swift.
MIT License
277 stars 44 forks source link

How to keep autoscrolling when the user starts scrolling manually? #44

Closed riyanpratamap closed 8 years ago

riyanpratamap commented 8 years ago

Hi, Is it possible to keep autoscrolling after user start to scroll it manually?

And yes, I'd like to say thank you for your amazing library.

evgenyneu commented 8 years ago

Hi @riyanpratama, thank you for good question and kind words. One can detect the "finger up" event and restart autoscrolling with a scroll view delegate. Here is an example:

class ViewController: UIViewController, UIScrollViewDelegate {
  @IBOutlet weak var scrollView: UIScrollView!

  override func viewDidLoad() {
    super.viewDidLoad()

    scrollView.delegate = self

    scrollView.auk.show(url: "https://bit.ly/auk_image")
    scrollView.auk.show(url: "https://bit.ly/moa_image")
    scrollView.auk.startAutoScroll(delaySeconds: 2)
  }

  func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
    scrollView.auk.startAutoScroll(delaySeconds: 2)
  }
}

Let me know how/if it works for you.

riyanpratamap commented 8 years ago

It works and you're really kind! Thank you.

erayalparslan commented 5 years ago

@evgenyneu thank you very much