JTAppleCalendar icon indicating copy to clipboard operation
JTAppleCalendar copied to clipboard

Enable scrollToDate on year view

Open RomuloVHSYS opened this issue 6 years ago • 2 comments

I want a scrollToDateor scrollToMonth method for the new Year View

So i can scroll to the month of my need

RomuloVHSYS avatar May 23 '19 21:05 RomuloVHSYS

With workaround without having an official method, i have implemented my own way to scroll to a specific Date:

func scroll(toDate date: Date, at: UICollectionView.ScrollPosition = .centeredVertically, animated: Bool = true, considerMonth: Bool = true){
        let yearToScroll = c.component(.year, from: date)
        let currentYear = c.component(.year, from: Date())
        let monthToScroll = considerMonth ? c.component(.month, from: date) : 0
        let itemIndex = (yearToScroll - (currentYear-100)) * 12 + (yearToScroll - (currentYear-100))+monthToScroll
        
        self.yearView.scrollToItem(at: IndexPath(item: itemIndex, section: 0), at: at, animated: animated)
    }

Maybe it can help you @patchthecode

RomuloVHSYS avatar Jun 18 '19 17:06 RomuloVHSYS

unfortunately function
self.yearView.scrollToItem(at: IndexPath(item: itemIndex, section: 0), at: at, animated: animated) not scrolling calendarYear to specified IndePath

it is called and some strange action happens (in mili seconds of time) but calendarYear still starts from the very beginning (

scrollToItem func is definitely getting called since if I put very big row for IndexPath it crashes.

@patchthecode macOs 10.14 Mojave xcode 11.3 JtAppleCalendar github "patchthecode/JTAppleCalendar" "master" using carthage

zero-tolerance0 avatar Jan 30 '20 21:01 zero-tolerance0