summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-08-23 15:49:09 -0400
committerJulian Rex <julian.rex@mapbox.com>2019-08-26 08:09:00 -0400
commit8f568f32d617a5851d2cc8740ae482c238671f7c (patch)
treecfc37344eff8a4ae147b9376019fb64aa73049a2
parentaaeeaffdc3d22f57b01f4660bcead4277f7953c4 (diff)
downloadqtlocation-mapboxgl-8f568f32d617a5851d2cc8740ae482c238671f7c.tar.gz
[core] Call transitionFinishFn for jumpTo, and in case of NaN parameters.
-rw-r--r--include/mbgl/map/camera.hpp4
-rw-r--r--src/mbgl/map/transform.cpp12
-rw-r--r--src/mbgl/map/transform.hpp2
3 files changed, 14 insertions, 4 deletions
diff --git a/include/mbgl/map/camera.hpp b/include/mbgl/map/camera.hpp
index c8b665fc16..456c0eeb56 100644
--- a/include/mbgl/map/camera.hpp
+++ b/include/mbgl/map/camera.hpp
@@ -94,6 +94,10 @@ struct AnimationOptions {
/** Creates an animation with the specified duration. */
AnimationOptions(Duration d)
: duration(d) {}
+
+ AnimationOptions(std::function<void()> finish)
+ : transitionFinishFn(finish) {}
+
};
} // namespace mbgl
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index d386898c3b..495aacd9bd 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -72,8 +72,8 @@ CameraOptions Transform::getCameraOptions(const EdgeInsets& padding) const {
* a transition. The map will retain the current values for any options
* not included in `options`.
*/
-void Transform::jumpTo(const CameraOptions& camera) {
- easeTo(camera);
+ void Transform::jumpTo(const CameraOptions& camera, const AnimationOptions& animation) {
+ easeTo(camera, animation);
}
/**
@@ -96,6 +96,9 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch();
if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch)) {
+ if (animation.transitionFinishFn) {
+ animation.transitionFinishFn();
+ }
return;
}
@@ -172,6 +175,9 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch();
if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch) || state.size.isEmpty()) {
+ if (animation.transitionFinishFn) {
+ animation.transitionFinishFn();
+ }
return;
}
@@ -273,7 +279,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
}
if (duration == Duration::zero()) {
// Perform an instantaneous transition.
- jumpTo(camera);
+ jumpTo(camera, animation.transitionFinishFn);
return;
}
diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp
index ffeff3859c..8fdfb333f3 100644
--- a/src/mbgl/map/transform.hpp
+++ b/src/mbgl/map/transform.hpp
@@ -32,7 +32,7 @@ public:
CameraOptions getCameraOptions(const EdgeInsets&) const;
/** Instantaneously, synchronously applies the given camera options. */
- void jumpTo(const CameraOptions&);
+ void jumpTo(const CameraOptions&, const AnimationOptions& = {});
/** Asynchronously transitions all specified camera options linearly along
an optional time curve. However, center coordinate is not transitioned
linearly as, instead, ground speed is kept linear.*/