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

Months don't snap to their edge #207

Open
jlindenbaum opened this issue Sep 16, 2015 · 14 comments
Open

Months don't snap to their edge #207

jlindenbaum opened this issue Sep 16, 2015 · 14 comments

Comments

@jlindenbaum
Copy link

When flicking the calendar left / right between months the calendar does not always properly stop at the month's edge, it can go further, or not far enough. This leads to the menu view and the calendar itself being in a weird state.

Simulator: 5S running 8.4
JTCalendar: 2.1.4

screen shot 2015-09-16 at 13 50 54

screen shot 2015-09-16 at 13 50 48

@jonathantribouharet
Copy link
Owner

I remember having this bug but I don't remember how I solve it and what was it's origin, I think it's coming from the menu view or the synchronisation between the menu view and the calendar.
Can you create a repository with a project with the same configuration?

@ty-sang
Copy link

ty-sang commented Sep 18, 2015

Try [calendar reloadAppearance] and [calendar repositionViews] in viewDidLayoutSubviews, that solved my for me.

hope this will help

@jlindenbaum
Copy link
Author

@jonathantribouharet I will try and spike this out into a separate project I can upload here. But the setup is basically as simple as your examples.

@SHIEER must be part of the 1.x versions, in 2.x those are not public selectors.

But, when I perform them regardless, it seems to lessen how often the problem appears, but the problem still persists frequently enough to be blocking me from updating.

- (void)viewDidLayoutSubviews {
    [_calendarMenu performSelector:@selector(repositionViews)];
    [_calendarContent performSelector:@selector(repositionViews)];
}

@jonathantribouharet
Copy link
Owner

Yes it's from 1.x version, event if repositionViews method still exist, it's a full rewrite of the code.
If I can't reproduce the bug it's complicated to fix it for me. I wait until you create a repository with just this controller for debug it.

@ty-sang
Copy link

ty-sang commented Sep 19, 2015

it is 1.x version, sorry, i didn't see you are on 2.x

@tomdalling
Copy link

Just wanted to "plus one" this and say that I've hit the same bug. I've tried to create a minimal reproducible example project, but I can't trigger the bug outside of my app.

palcalde pushed a commit to palcalde/JTCalendar that referenced this issue Oct 28, 2015
palcalde pushed a commit to palcalde/JTCalendar that referenced this issue Oct 28, 2015
@palcalde
Copy link

@tomdalling @SHIEER @jlindenbaum check the pullrequest: #218. Hopefully works for your projects.

@jlindenbaum
Copy link
Author

@palcalde I've replaced your fixes in my JTHorizontalCalendar - it doesn't seem to address the fix - I can go correctly in one direction, but after one or two swipes in the other direction the same issue reappears.

@tomdalling
Copy link

Here's a minimal reproduction project that shows the issue (see the README): https://github.com/tomdalling/JTCalendarBugReproduction

I tried PR #218, and it mostly works. It causes some weirdness when repeatedly tapping the "Next Month" button in the JTCalendarBugReproduction project. Tapping "Next Month" while the sliding animation is in progress slows down the animation.

I'm not sure if it fixes the exact issue I was having in my app. Some recent unrelated changes to my app seem to have made the bug disappear, although I'm not sure why.

@palcalde
Copy link

Hey @tomdalling you are right, tapping multiple times on back works great but doing it in next month slows down the animation (at least doesn't break the calendar as before).

I've udpated the #218 with a new commit that allows tapping on next multiple times without slowing the animation. Check it out.

@jonathantribouharet
Copy link
Owner

@tomdalling Thank you very much, I wasn't able to reproduce the bug.

I still don't know what exactly is the problem. I think it's when there is an interaction during the animation of the scrollview.

I may have a simple / dirty hack, after calling [_horizontalView loadPreviousPageWithAnimation]; or another method moving the scrollview call

[_horizontalView performSelector:@selector(repositionViews) withObject:nil];

This hack came from http://stackoverflow.com/questions/993280/how-to-detect-when-a-uiscrollview-has-finished-scrolling, I'm using it for UITableView in specific cases.
It's call repositionViews method (which is not public) but in the main thread and after the animation of the scrollview (a the end of a scroll for example because the delegate method cannot be used in some cases...).

@palcalde
Copy link

palcalde commented Nov 3, 2015

I haven't found issues after applying the changes in #218.

@veyhong
Copy link

veyhong commented Jan 7, 2016

Hi there, I have add some code it help a lot to let Months snap to their edge. Please help check I am not sure wether it will solve all problem or not, but after add this lines, I rarely see the problem or maybe I cannot reproduce the bug ? link: https://github.com/cvhong/JTCalendar/commit/350183375ca99d4199c39da7adceb5be5a9aa4cb

@lefty1
Copy link

lefty1 commented Apr 4, 2016

I get the problem as well. It happens when I call loadNextPageWithAnimation serveral time rapidly in succesion.
The bug seem to be with the calculation of contentOffset.
I figured out a temporary workaround anyway.

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

No branches or pull requests

7 participants