nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
12k stars 2.58k forks source link

Scroll One item at a time #810

Open Abhishek-NickelFox opened 7 years ago

Abhishek-NickelFox commented 7 years ago

Currently using time machine type and need to scroll to just next item . irrespect of how fast i have scrolled in screen

Abhishek-NickelFox commented 7 years ago

@nicklockwood : PLz help

6axter82 commented 7 years ago

This is how I do it for .rotary type This code I have got from some issue described here, can't remember which one it was. I suggest you to go through some of the issues and read them. It is very informative.

@IBOutlet var carouselView: iCarousel!
override func viewDidLoad() {
super.viewDidLoad()
 carouselView.dataSource = self
 carouselView.delegate = self
 carouselView.type = .rotary

 carouselView.isScrollEnabled = false
 carouselView.isPagingEnabled = true

 let swipeGestureLeft = UISwipeGestureRecognizer(target: self, action: #selector(self.swipeCarouselLeft))
            swipeGestureLeft.direction = .left
            carouselView.addGestureRecognizer(swipeGestureLeft)

 let swipeGestureRight = UISwipeGestureRecognizer(target: self, action: #selector(self.swipeCarouselRight))
            swipeGestureRight.direction = .right
            carouselView.addGestureRecognizer(swipeGestureRight)
}

func swipeCarouselLeft(sender: UISwipeGestureRecognizer) { carouselView.scroll(byNumberOfItems: 1, duration: 0.1) }

func swipeCarouselRight(sender: UISwipeGestureRecognizer) { carouselView.scroll(byNumberOfItems: -1, duration: 0.1) }
6axter82 commented 7 years ago

I tried it with your .timeMachine type, it worked as well.

Abhishek-NickelFox commented 7 years ago

@6axter82 : i 'm using in vertical direction