patchthecode / JTAppleCalendar

The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable
https://patchthecode.com
MIT License
7.57k stars 812 forks source link

scrollToDate extraAddedOffset does not work #548

Closed jesus-rod closed 1 year ago

jesus-rod commented 7 years ago

I tried the following: myCalendarView.scrollToDate(firstDate, triggerScrollToDateDelegate: true, animateScroll: true, preferredScrollPosition: .top, extraAddedOffset: 30, completionHandler: nil)

Also tried passing negative or huge values but no difference at all. Is this normal?

I am accomplishing what I want in a not so clean way by using the didScrollToDateSegment delegate but would love not having to do that...

patchthecode commented 7 years ago

hmm. I might have broke something. Let me check.

patchthecode commented 7 years ago

Does your calendarView have any headers which scroll with the calendar?

Also, can you try the master branch and let me know if your issue is resolved there? put this in your Podfile and then do a pod update

pod 'JTAppleCalendar', :git => 'https://github.com/patchthecode/JTAppleCalendar.git', :branch => 'master'

Master branch has a significant change.

  1. you must implement willDisplayCell. The code you put in there, is pretty much the same code you put in your cellForItemAtIndex function

Let me know if you are still experiencing this.

jesus-rod commented 7 years ago

😩😩 I will be waiting for the new version to be released, I am doing several workarounds for a couple of things that apparently have been fixed on the master branch

patchthecode commented 7 years ago

You can use master branch, i actually need more testers. I would hate to release it and something else broke somewhere else.

Or maybe you can let me know what was fixed. I am in the dark as to what errors there are if no one lets me know :)

jesus-rod commented 7 years ago

How can I help you to test? I want to contribute since I've been using this library quite a bit lately.. Besides the problem mentioned in this post, the other thing I am working around is using the viewDidScroll delegate that I implemented myself instead of using the one on the master branch that probably needs testing too.

patchthecode commented 7 years ago

Testing is simply using the master branch code. If you see any issues, even the smallest of issues, then let me know and i'll fix.

Right now there are only few people using master branch, therefore, when i take the master branch code and convert into the latest version for everyone else, there might be some parts we missed.

The master branch code, becomes the released version when we have removed all bugs we can find.

patchthecode commented 7 years ago

you can even zip parts of fixes you have worked on, and drop it in chatbox here. Or you can create a github pull request if you prefer that option. That way this library will gradually become better.

divbyzero commented 6 years ago

JTAppleCalendar/Sources/InternalActionFunctions.swift [7.1.5 and master]

func scrollTo(indexPath: IndexPath, triggerScrollToDateDelegate: Bool, isAnimationEnabled: Bool, position: UICollectionViewScrollPosition, extraAddedOffset: CGFloat, completionHandler: (() -> Void)?) {
isScrollInProgress = true
        if let validCompletionHandler = completionHandler { scrollDelayedExecutionClosure.append(validCompletionHandler) }
        self.triggerScrollToDateDelegate = triggerScrollToDateDelegate
        DispatchQueue.main.async {
            self.scrollToItem(at: indexPath, at: position, animated: isAnimationEnabled)
            if (isAnimationEnabled && self.calendarOffsetIsAlreadyAtScrollPosition(forIndexPath: indexPath)) ||
                !isAnimationEnabled {
                self.scrollViewDidEndScrollingAnimation(self)
            }
            self.isScrollInProgress = false
        }
    }

extraAddedOffset - the parameter is not used in this method.

The issue is not resolved.

patchthecode commented 6 years ago

@divbyzero

what command you running that ends up at this code path? hmm... i'll have to take a look at this. Probably i missed it

divbyzero commented 6 years ago

I used this settings:

calendar.scrollDirection = .vertical
calendar.scrollingMode = .nonStopToCell(withResistance: 0)

and this method:

calendar.scrollToDate(date, triggerScrollToDateDelegate: false, animateScroll: true,
                              preferredScrollPosition: .centeredVertically,
                              extraAddedOffset: 50,
                              completionHandler: nil)
patchthecode commented 6 years ago

I'll take a look.

yuryks commented 5 years ago

Are there any updated on this issue ?

patchthecode commented 5 years ago

@yuryks finally had a chance to look into this. (Was really busy).

a UICollecitonView has 2 method to automatically scroll to a cell.

  1. self.scrollToItem(at: indexPath, at: UICollectionView.ScrollPosition, animated: Bool)

    &

  2. self.setContentOffset(point: CGPoint, animated: Bool)

I have added the ability to set an extra offset for the method (2) seen above. This is because i have access to the point and therefore, i can add or subtract extraContent offset.

The (1) above gives the ability to put a preferredPosition. The (2) above gives the ability to use a CGPoint and therefore an axtra content offset.

What user @divbyzero has done is asked for 2 things. He wants BOTH a UICollectionView.ScrollPosition together with a ContentOffset. But as we can see above, these are two different functions.

The mistake i have done with this library is that i have allowed a scroll to date function with the ability to do both in a single function. But both cannot be done. It should be either one function with a preferredPosition and another function with a contentOffset. There should not be one funciton with both.

I will change this in a future update.

yuryks commented 5 years ago

@patchthecode Thanks. For now my workaround is: completionHandler: { self.calendarView.contentOffset.y += 20})

JigneshBlogers commented 5 years ago

Hi

I am getting Showing All Errors Only :-1: Missing package product 'JTAppleCalendar', please fix package resolution errors before building (in target 'SampleJTAppleCalendar')

How can i fix this?

patchthecode commented 5 years ago

@jigneshKCTS the question you are asking is not related to this issue. Can you please open a new request? And please fill in the information requested when you open the new request. -> Because without this missing information, I have no idea how to help.