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

Fixed colliding animations #99

Merged
merged 1 commit into from
Jan 7, 2016
Merged

Conversation

adamcohenrose
Copy link
Contributor

I noticed that sometimes the callout appeared and immediately disappeared -- turns out the animations were colliding.

To repeat issue:

  1. use SMCalloutView with an MKMapView on iOS 9.2
  2. have more than one annotation visible on the map so that the map does not need to scroll between callouts
  3. also have a current location annotation on the same map
  4. touch an annotation to show the SMCalloutView
  5. touch the current location annotation to show the built-in "Current Location" callout -- the SMCalloutView will correctly disappear
  6. touch another annotation -- the SMCalloutView will appear and immediately disappear

Debug logging showed that the animations were getting out of order even though the dismissCalloutAnimated: was called before the presentCalloutFromRect:... method.

The "present" animation was not assigned a delay as there was no need to move the map, so the animations could happen in any order. For some reason, showing the current location callout triggered a switch in the order.

I noticed that sometimes the callout appeared and immediately disappeared -- turns out the animations were colliding.

To repeat issue:

1. use SMCalloutView with an MKMapView on iOS 9.2
2. have more than one annotation visible on the map so that the map does not need to scroll between callouts
3. also have a current location annotation on the same map
4. touch an annotation to show the SMCalloutView
5. touch the current location annotation to show the built-in "Current Location" callout -- the SMCalloutView will correctly disappear
6. touch another annotation -- the SMCalloutView will appear and immediately disappear

Debug logging showed that the animations were getting out of order even though the `dismissCalloutAnimated:` was called before the `presentCalloutFromRect:...` method.

The "present" animation was not assigned a delay as there was no need to move the map, so the animations could happen in any order. For some reason, showing the current location callout triggered a switch in the order.
@nfarina
Copy link
Owner

nfarina commented Jan 7, 2016

So the problem here is that these commands are being sent to a single SMCalloutView instance in rapid succession:

[self.calloutView dismissCalloutAnimated:YES];
[self.calloutView presentCalloutFromRect:... inView:... constrainedToView:... animated:YES];

Because the default dismiss animation is a "fade" with a duration of 0.33 seconds, it "lasts longer" than the default presenting animation of "bounce" with 0.23 seconds—so the fade finishes last and removes the callout view from the screen. And regardless, it fades out while presenting which is undesirable.

Your fix is appropriate for this I believe, since as a user I would expect calling present to "override" the previous call to dismiss.

Thanks for tracking this down and for putting the PR together - I will merge now!

nfarina added a commit that referenced this pull request Jan 7, 2016
@nfarina nfarina merged commit 74ca346 into nfarina:master Jan 7, 2016
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

Successfully merging this pull request may close these issues.

2 participants