From 986e0ae39e8a301a3fb6a2cb5f852da3a30417f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 17 Dec 2015 10:24:58 -0800 Subject: [PATCH] [core] Added special case for atomic flyTo() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit startTransition isn’t well-suited to atomic transitions, which are expected to be synchronous and end up at the final state. --- src/mbgl/map/transform.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index d08972d53..58541ccfa 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -373,7 +373,7 @@ void Transform::flyTo(const CameraOptions &options) { double S = (is_close ? (std::abs(std::log(w1 / w0)) / rho) : ((r(1) - r0) / rho)); - Duration duration = flyOptions.duration ? *flyOptions.duration : Duration::zero(); + Duration duration; if (flyOptions.duration) { duration = *flyOptions.duration; } else { @@ -381,6 +381,11 @@ void Transform::flyTo(const CameraOptions &options) { duration = std::chrono::duration_cast( std::chrono::duration(S / speed)); } + if (duration == Duration::zero()) { + // Atomic transition. + jumpTo(options); + return; + } startTransition( [=](double t) { util::UnitBezier ease = flyOptions.easing ? *flyOptions.easing : util::UnitBezier(0, 0, 0.25, 1);