Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visible scrolling when trying to start calendar at a certain date #263

Closed
dbmrq opened this issue Jan 13, 2017 · 26 comments
Closed

Visible scrolling when trying to start calendar at a certain date #263

dbmrq opened this issue Jan 13, 2017 · 26 comments

Comments

@dbmrq
Copy link

dbmrq commented Jan 13, 2017

My calendar has a pretty broad range, starting about 10 years ago.

I want the calendar to be on the current date when it first appears, so I do calendarView.scrollToDate(Date()) at viewDidLoad().

When I go to the calendar's view controller, I can se the previous months flash very quickly, and then the current month shows up (even if I use animateScroll = false).

I didn't try it, but I think this question and some of its answers could be useful: http://stackoverflow.com/q/18087073/3539651

Maybe this too:
http://stackoverflow.com/a/26247477/3539651

@patchthecode
Copy link
Owner

patchthecode commented Jan 14, 2017

OK. i will look into this. Thanks for finding.

@patchthecode
Copy link
Owner

I think I have now fixed this.

@dbmrq
Copy link
Author

dbmrq commented Mar 20, 2017

Awesome, thank you. :)
How about the orientation stuff, any news?

@patchthecode
Copy link
Owner

patchthecode commented Mar 20, 2017

Almost done.
Just testing it now.

@dbmrq
Copy link
Author

dbmrq commented Mar 20, 2017

Cool, thanks! 🎉

@patchthecode
Copy link
Owner

Issue resolved on version 7.0
Releasing Beta version this weekend.

@dbmrq
Copy link
Author

dbmrq commented Mar 29, 2017

Awesome, thank you! 👏

@patchthecode
Copy link
Owner

patchthecode commented Mar 29, 2017

I hope it works well for you.
I used your idea. I provide a delegate when orientation changes willTransitionToSize
let's see how that goes.

@z3bi
Copy link
Contributor

z3bi commented Apr 13, 2017

@dbmrq does version 7.0 resolve the visible scrolling issue? I'm using version 7.0 and call calendarView.reloadData(with: Date(), animation: false) inside viewDidLoad but can also see the previous months quickly flash before showing the current month.

@patchthecode
Copy link
Owner

@z3bi hmm.. you are reloading data on viewDidLoad..
is there any reason we are reloading data on the view did load?

At this point, the calendar is not even setup yet. So reloading will not really do anything.
if your objective is to scroll to a date on view did load, then
remove this -> calendarView.reloadData(with: Date(), animation: false)
and replace it with this calendarView.scrollToDate(Date())
let me know if this helps?

@z3bi
Copy link
Contributor

z3bi commented Apr 13, 2017

@patchthecode same behavior, here is what I am doing now:

override func viewDidLoad() {
        super.viewDidLoad()
        
        calendarView.scrollToDate(Date(), triggerScrollToDateDelegate: true, animateScroll: false, preferredScrollPosition: nil, extraAddedOffset: 0) { 
            self.calendarView.selectDates([Date()], triggerSelectionDelegate: true, keepSelectionIfMultiSelectionAllowed: false)
        }
    }

@patchthecode
Copy link
Owner

@z3bi ok let me know how many years of date that you generate please?

I will try to re-create this issue on my end

@z3bi
Copy link
Contributor

z3bi commented Apr 13, 2017

@patchthecode I'm just doing one year prior to today until one year after today. I'll try to recreate it in a sample project for you.

@z3bi
Copy link
Contributor

z3bi commented Apr 13, 2017

@patchthecode here is a repo with an example https://github.com/z3bi/JTAppleCalendarExample

It can be hard to see it in the simulator, but it is consistently noticeable running on an iPhone 7. The flash is pretty brief, but I just wanted to see if perhaps I'm doing something incorrectly or if it's just unavoidable.

@patchthecode
Copy link
Owner

@z3bi as the original poster shows, this seems to be an issue with UICollectionView. I'm not sure of the best way to handle this. Therefore, for now, I have set the help wanted flag to this issue.

@patchthecode
Copy link
Owner

@z3bi on 2nd thought, i think i found something. I can set the content offset inside the prepare() function. Right now i am investigating the possible side effects.

@dbmrq
Copy link
Author

dbmrq commented Apr 14, 2017

I didn't get the chance to try version 7 yet, but if the UICollectionView itself is exposed maybe we could use some of the answers to the Stack Overflow questions I posted (the hack we talked about, @patchthecode). Not the most elegant solution, but it's something. I'll look into it as soon as I can.

@patchthecode
Copy link
Owner

@dbmrq thanks man. I'd really appreciate the help if you can

@patchthecode
Copy link
Owner

@z3bi can you let me know if this is a fix ?
JTAppleCalendarExample.zip

@z3bi
Copy link
Contributor

z3bi commented Apr 15, 2017

@patchthecode yeah that worked great, can't notice any dates changing when the view loads. 👍

@patchthecode
Copy link
Owner

@z3bi awesome i will look at the changes again, and then get a new build for 7.0.2 up
thanks for the assistance

@patchthecode
Copy link
Owner

@dbmrq seems i found something from the links you provided

@dbmrq
Copy link
Author

dbmrq commented Apr 15, 2017

Ah, awesome, I'm sorry I couldn't help more. I'll still take a look when I can, I've been really busy lately.

@patchthecode
Copy link
Owner

@dbmrq its cool man. You've a;ready helped quite a bit

patchthecode added a commit that referenced this issue Apr 18, 2017
@patchthecode
Copy link
Owner

@z3bi i just pushed the change to master branch. I hope i didnt break any thing :)
Seems well after i tested.

@z3bi
Copy link
Contributor

z3bi commented Apr 18, 2017

@patchthecode awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants