Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Map "settling" animation doesn't cancel with cancelTransitions #5905

Closed
sddamico opened this issue Aug 8, 2016 · 4 comments
Closed

Map "settling" animation doesn't cancel with cancelTransitions #5905

sddamico opened this issue Aug 8, 2016 · 4 comments
Labels
Android Mapbox Maps SDK for Android

Comments

@sddamico
Copy link

sddamico commented Aug 8, 2016

I'm writing a method to prevent the camera from exiting a certain bounds (workaround for #3602). "Pseudocode":

Bounds constraintBounds = new Bounds(...);

mapView.postOnAnimation(() -> {
  checkBounds();
  mapView.postOnAnimation(this);
});

checkBounds() {
  CameraPosition cameraPosition = map.getCameraPosition();
  Bounds visibleBounds = map.getVisibleBounds(); 

  if (visibleBounds.outside(constraintBounds)) {
    map.moveCamera(CameraUpdateFactory.newLatLng(cameraPosition.plus(contraintBounds.diff(visibleBounds)));
  }
}

This works for the most part except for during the "settling" animation that occurs after a swipe.

swipe_animation_bug_mapbox

Platform: Android
Mapbox SDK version: 4.2.0-SNAPSHOT

Steps to trigger behavior

  1. Write bounds checking/camera updating method similar to above
  2. Try to enable settling animation by swiping rapidly on map view

Expected behavior

moveCamera()'s call to cancelTransitions() would cancel settling animation, preventing camera from exiting bounds.

Actual behavior

Animation continues.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Aug 8, 2016
@tobrun
Copy link
Member

tobrun commented Nov 2, 2016

Adding this to the 4.2.0 milestone since we have had some requests around this feature.

@tobrun tobrun added this to the android-v4.2.0 milestone Nov 2, 2016
@tobrun
Copy link
Member

tobrun commented Nov 3, 2016

Looked into this and seemed different than I initially thought. Moving it of the milestone for now, the issue I looked in is PR'ed in #6891. @sddamico have you tried hooking into using MapboxMap.OnFlingListener? This is called as part of the swipe/fling.

@tobrun tobrun removed this from the android-v4.2.0 milestone Nov 3, 2016
@sddamico
Copy link
Author

sddamico commented Dec 9, 2016

@tobrun I had tried the fling listener previously, yes. My issue here was that calling moveCamera on every frame should cancel a running animation.

@sddamico
Copy link
Author

The thing that I was trying to do is now solved with viewport restrictions, closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

2 participants