JTAppleCalendar icon indicating copy to clipboard operation
JTAppleCalendar copied to clipboard

scrollToDate extraAddedOffset does not work

Open jesus-rod opened this issue 7 years ago • 16 comments

  • Using version 7.0.6
  • I have a vertical calendar I am trying to scroll to a date but because of my design, I have an overlapping view over the JTAppleCalendarView. Hence, I need to offset the scrolling about 30px more but when I try to pass values in the extraAddedOffset field, it does not make any difference.

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...

jesus-rod avatar Aug 30 '17 11:08 jesus-rod

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

patchthecode avatar Aug 30 '17 13:08 patchthecode

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.

patchthecode avatar Aug 31 '17 05:08 patchthecode

😩😩 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

jesus-rod avatar Aug 31 '17 11:08 jesus-rod

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 :)

patchthecode avatar Aug 31 '17 18:08 patchthecode

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.

jesus-rod avatar Aug 31 '17 18:08 jesus-rod

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 avatar Aug 31 '17 19:08 patchthecode

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.

patchthecode avatar Aug 31 '17 19:08 patchthecode

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.

divbyzero avatar Feb 07 '18 13:02 divbyzero

@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

patchthecode avatar Feb 07 '18 17:02 patchthecode

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)

divbyzero avatar Feb 07 '18 21:02 divbyzero

I'll take a look.

patchthecode avatar Feb 08 '18 01:02 patchthecode

Are there any updated on this issue ?

yuryks avatar Mar 06 '19 11:03 yuryks

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

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

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.

patchthecode avatar Mar 07 '19 20:03 patchthecode

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

yuryks avatar Mar 11 '19 12:03 yuryks

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?

JigneshBlogers avatar Sep 14 '19 19:09 JigneshBlogers

@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.

patchthecode avatar Sep 15 '19 02:09 patchthecode